Code Monkey home page Code Monkey logo

alm's People

Contributors

gatlin avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

stellatigre

alm's Issues

Remove Signal IDs

Notifying an input signal shouldn't involve a loop. The signal's ID should just be its position in an array.

Virtual DOM is recreated from scratch on each view update

Right now the pattern is to completely recreate the virtual DOM tree and then completely re-render the view every time something on screen needs to change.

The vdom should instead be a persistent model initialized with the application which provides a special mailbox to where the rest of the application can send view updates (of some special form).

The vdom would listen to this mailbox and modify the DOM based on what it receives. How it goes about re-rendering these changes is for a separate issue.

Things to consider: how should tree updates be specified?

Include DOM helpers in some backward-compatible place

I keep writing little things while using Alm and I really should put them in the standard library somewhere.

For example, this little routine finds the first ancestor of an element which has a certain class:

    runtime.scope.ancestorWithClass = function(node, needle) {
        function hasClass(node, needle) {
            return (' ' + node.className + ' ').indexOf(' ' + needle + ' ') > -1;
        }

        let haystack = node;
        while (node) {
            if (hasClass(haystack, needle)) {
                break;
            } else {
                haystack = haystack.parentNode;
            }
        }
        return haystack;
    };

"Controller" wrapper around `App` for common design pattern

A common pattern that is emerging looks like this:

  • A single model as a signal reduction
  • listens to updates from an "updates" or "actions" mailbox, and
  • a view which listens directly to updates from the model signal
  • 0 or more event listeners based on events or other existing signals
  • 0 or more ports

All of these things need to be visible to one another, of course, but I think a wrapper function or class around App - say, Controller - would be really useful for streamlining everything.

App event and DOM scopes shouldn't necessarily be the same

What an App has control over and what it can listen to should be separate.

  • If a configuration object is passed, it is expected that separate elements are given for event root and DOM root.
  • If a single id is passed, then they are the same.
  • If nothing is passed, the defaults are the document body for both.
  • If a configuration object is passed but either key is null, default is document.body.

vdom mailboxes

It should be possible to assign a DOM node a mailbox it sends itself to once it has been (re-)rendered.

Use case: the application requires a canvas to draw on, so you want to initialize a drawing module with the context once it's available. You could listen on the mailbox for that node and be notified every time the node is drawn (or redrawn) and use that to continue with any drawing-related activities.

Pull-based signals

The current signal system is push-based, which has a number of desirable properties. However, since they do not have values themselves[^1] you can't poll for events, either. In "event/behavior" terminology we have "events" and could use "behaviors."

What is the best way to do this? And should signals be reimplemented a little more rigorously in relation to the App monad?

[^1] that you can access at will. Reducers haven hidden state.

Signals should memoize results

This would entail keeping a cache of all values seen. Depending on the complexity of the signal function this may end up just wasting more memory with negligible performance benefits, but it is worth looking into.

Tasks

Whether it is based on promises or something homebrewed it would be useful to have a system for orchestrating asynchronous tasks in such a way that reads well in code, is efficient, and which is expressive while making it difficult to write something incorrect.

To steal another term and idea from Elm, I call this hypothetical system "tasks."

Less naive DOM diffing algorithm

The way the vdom diffs children elements is naive and in more complex cases could lead to massive re-rendering of DOM nodes where it isn't strictly necessary.

Do something about loeb.js

For now it should probably be combined into the alm source, as it currently has 1 user. I can split it out again later.

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.