GithubHelp home page GithubHelp logo

frugality / liveflow.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hasharray/liveflow.js

0.0 1.0 0.0 471 KB

Live Editing for Node.js and Browsers

Home Page: https://thingamajig.js.org

Makefile 2.68% HTML 16.51% JavaScript 80.81%

liveflow.js's Introduction

Liveflow.js - Live Editing for Node.js and Browsers

Liveflow.js is a small runtime extension that enables live-editing of scripts as-well as live-reloading of required json files.

It's a pure, self-contained JavaScript based implementation with no external parts and should work in any more or less any JavaScript runtime, be it Node.js, Chrome, Firefox, Safari, Internet Explorer or Microsoft Edge.

Features

Live Editing of Scripts

Whenever scripts are changed on disk, across the network or within the document object model itself (e.g inline script tags) the source of that script is re-evaluated in its original execution context.

Re-evaluation means the following things:

  • Modified and new top level call expressions are called.
  • Surviving call expressions yield their previous value.
  • Function modifications are applied.
Live Reloading of Documents

Whenever a document is changed on disk or across the network, the page will be reloaded.

Live Reloading of Style Sheets

Whenever style-sheets are changed on disk or across the network, the old style link will be replaced with a new one causing the style-sheet to reload.

Live Reloading of Images

Whenever image sources are changed on disk or across the network, the image elements linking to that file will be reloaded.

Live Reloading of JSON

Whenever the source of a JSON file changes on disk that has been imported with require, it will reload and replace the key/value pairs on the original object.

This only applies to Node.js environments.

Getting Started

Liveflow.js has been designed to be as configuration free as possible, just include the script in your runtime environment and be done with it.

Node.js

  1. Install the thingamajig module.
npm install thingamajig
  1. Start node with the --require (shorthand -r) option, passing in thingamajig as the module name to require.
node -r thingamajig myapp.js
    1. Enjoy live editing and reloading.

If you want to do your own post-processing in addition to what thingamajig does, add a listener on the reload event.

proces.on('reload', function(module) {
  console.log(module.filename, 'reloaded');
});

Browser

  1. Include the following script at the very top of the head section in your document, it should be the first element after the opening <head> tag.
<script src="//thingamajig.js.org/thingamajig.js"></script>
  1. Open the document in your preferred browser.

  2. Enjoy live editing and reloading.

If you want to do your own post-processing in addition to what thingamajig does, add an event listener to the reload event.

document.addEventListener('reload', function(event) {
  console.log(event.target);
});

Documentation

See [https://thingamajig.js.org].

License

MIT

liveflow.js's People

Contributors

caspervonb avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.