Skip to content

QUESTION: Should we use use Immutable? #43

@dchambers

Description

@dchambers

If we used Immutable then we could:

  1. Skip further processing if a handler's output is unchanged.
  2. Update all derived handler inputs after each handler has run (this means less copying, since only a subset of a handler's input properties are likely to have changed).
  3. Only run a handler if it's input properties have changed.
  4. Know that the handler hadn't interfered with the input it had been given.

The upshot of this would be that, a summation-handler that is currently implemented like this:

function summationHandler(['x', 'y'], ['sum'], function(input, output, prevInput, prevOutput) {
    output.sum = input.x + input.y;
})

would now be implemented like this:

function summationHandler(['x', 'y'], ['sum'], function(input, output, prevInput) {
    return output.set('sum', input.get('x') + input.get('y'));
})

If we switch to using recursion instead of iteration (as per #34), then we'd need to tie this in with the need to invoke output.apply(), so the code would need to be written like this instead:

function summationHandler(['x', 'y'], ['sum'], function(input, output, prevInput) {
    output.set('sum', input.get('x') + input.get('y')).apply();
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions