Skip to content

ripplejs/state

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

state

Batch all changes to an object until the next frame.

var State = require('ripplejs/state');

var data = {
  names: {
    first: 'Scott',
    short: 'Pilgrim'
  }
};

var state = new State(data);

// Stage a change to merge with the original object
state.set({
  names: {
    first: 'William'
  }
});

// Values aren't immediately commited
assert(data.names.first === 'Scott');

// Changes are committed on the next requestAnimationFrame
state.on('flush', function(changed){
  assert(changed[0] === 'names');
  assert(data.names.first === 'William');
});

Notes

  • Objects are merged together
  • It won't optimize if the values haven't actually changed

About

Batch all changes to an object until the next frame

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published