Skip to content

Releases: omniscientjs/omnipotent

v1.2.1

26 Oct 21:30
Compare
Choose a tag to compare

Obligatory patch release.

Bugfixes

  1. Changes life cycle method for observer and avoid removing references
  2. Fixes issue with unsubscribe for observer decorator

v1.2.0

26 Oct 19:56
Compare
Choose a tag to compare

Updates to the latest version of Omniscient.js (v4.0.0). Now depends on React 0.14.

Functions that are ignored through the ignore decorator will now not be swapped out if they are unchanged between renders. This means that the closed variables in callbacks won't update between renders. This logic was previously located in Omniscient core.

v1.1.0

21 Jul 23:05
Compare
Choose a tag to compare

Additions:

decorator.observer(structure, fields, decoratee)

The observer decorator is a very useful one if you need horizontal data
dependencies. If you require one of your components to get injected data
automatically and update everytime that data changes.

Fields passed to observer should be defined as the following:

{
  namePassedAsProps: ['nested', 'key', 'path'],
  anotherNamePassedAsProps: 'shallowKeyPath'
}

Require the decorator by doing:

var observer = require('omnipotent/decorator/observer');
// or
var observer = require('omnipotent').decorator.observer;

Examples:

var structure = immstruct({ hero { name: 'Natalia Romanova' } });

var Title = component('View', ({hero}) => {name.deref()});

var ObservedTitle = observer(structure, {
  hero: ['hero', 'name'] // key path in structure
}, Title);

render(ObservedTitle({}));

// Update structure and component
structure.cursor('hero').set('name', 'Black Widow');

// Also for things like async fetch
fetch('./hero.json')
  .then(r => r.json())
  .then(d => structure.cursor().set('hero', Immutable.Map(d));