19 Changelog en
Svinokot edited this page 1 month ago

Changelog

2.0.0-beta1

Added

  • Added async change detection
  • Added usefull change callback
  • Unified event model
  • New cache manager
  • Refactor lens-utils for more understanding

Fix

  • All callback now support new event model as well

1.6.4

Fix

  • Objects fields now compare correctly.

1.6.3

Fix

  • Notification of changes in subtree (stage 3) no more prevented at the node if value has setted to undefined.

Added

  • Added second argument in callback witch returns current lens node.
    const callback = (event, lens) => {
        // lens is current lens node
    }
    

1.6.2

Fix

  • lens.set(null), lens.set(undefined), lens.set({ foo: null }) or same now works correctly.

1.6.0

Chain and Factories

We desided to replace go(key, factory) to another notation. It was very difficult and little bit "boilerplate".

Previous notation (removed):

go(key, factory)

New notation (added):

go(key).chain(factory)

Formerly you needed to create intermediary node everytime. It did factory more complexly. At new notation we separated intermediary node creation and factory implementation. Previous one is node which you gave with go(key).

Previous notation (removed):

go('foo', (coreFactory) => (key, foo) => {
    const intermediaryNode = coreFactory(key, foo);
    return new Lens(...);
});

New notation (added):

go('foo').chain(foo => {
    /* foo is intermediary node */
    return new Lens(...);
});

Easy way to instance

We added possibility to add to node tree of extends of Lens instances. It still uses go() method but without factory. You need to write only class name or creatable prototype.

New notation:

class MyLens extends Lens {
  test() { return 'Hi!'; }
}

const myFoo = lens.go('foo', MyLens);
myFoo.test(); // Hi!

Changes of extending

We removed getFactory() method in class, beacouse this approach is not safety. If you wanted to make autocreation same node type, you should override go() method in class. If you do not, prototype will Lens type.

New notation:

class A extends Lens {
  /* without override */
}

class B extends Lens {
  go(key, instance) {
    return super.go(key, instance || B);
  }
}

lens // Lens
  .go('a', A) // A
  .go('oops') // Lens
  .go('b', B) // B
  .go('next') // still B

Removed

  • Lens Js
    • createCoreFactory()
    • getFactory() in class
  • Lens Utils
    • getConsistsCallback()
    • getMapper()

Added

  • Lens Utils
    • transform() instead getMapper()