Syncronization & Events

Dataset has a very rich event system that allows you to subscribe to a variety of events on your dataset. By default, this functionality is NOT ENABLED. This is because event bindings are created automatically in certain cases (see more about selection and filtering) and unless that functionality is needed, there's no reason to create the bindings.

To enable evented behavior, set the sync property to true when initializing your dataset.

var ds = new Miso.Dataset({
  data : [
    { one : 12,  two : 40,  three : 40 }
  sync : true

What are the effects of sync:true?

By setting sync to true, you are enabling syncronization of data between your original Dataset and anything derived from it such as:

Default Events

Presently, dataset fires the following events:

Event Fired When Precedence
add Fired when adding a row to the dataset by calling .add Primary
remove Fired when removing a row from the dataset by calling .remove Primary
update Fired when updating a row in the dataset by calling .update Primary
change Fired when calling .add, .remove or .update Secondary
sort Fired when a dataset has been sorted. Primary
reset Fired when a dataset has been reset Primary

Any of the default events can be prevented by passing the { silent : true } flag. See the appropriate methods for further instructions.


To subscribe to an event, call subscribe like so:

ds.subscribe("add", callback);

Event Object

When any of the default events trigger (except for sort) an event object gets created and passed down to the callbacks. The event object is structured as follows:


An event is comprised of one or more deltas. Each delta can represent a different operation, allowing a single event to actually represent many modifications.

Each delta can look as follows:

  // the set of attributes that changed
  changed : { } or value

  // the old values of those attributes
  old : { } or value

Detecting Delta Types:

You can always check what type of a delta you've recieved by calling any of the following helper methods:


For example:

You can edit the code in this block and rerun it.

Custom Events

You can publish your own custom events on dataset by just calling publish when needed like so:

ds.publish("myCustomEvent", arguments...);

« Accessing Data

Modifying Data »