Skip to content

v0.5.0

Compare
Choose a tag to compare
@kentmw kentmw released this 19 Feb 15:58
· 496 commits to master since this release

A number of breaking changes and API updates were introduced with v0.5.0, all of which occured in View.js

Breaking Changes:

  1. render method should no longer be overridden. If you are attaching child views, move that logic into a method named attachTrackedViews. If you were doing custom logic in your render method, consider moving it into prerender that happens before the render logic, or into postrender that happens after all the rendering is complete.
  2. unplug and plug were renamed to prerender and postrender respectively and are always called by render
  3. attach method was renamed to attachTo
  4. injectView was removed. Use attachView which now takes an injection site name string or an element as the first parameter. This totally encompased the usefulness of injectView so it was removed.
  5. invokeAttached and invokeDetached were made private: __invokeAttached and __invokeDetached
  6. activateTrackedViews and deactivateTrackedViews were made private: __activateTrackedViews and __deactivateTrackedViews
  7. #197 - All public "child" view methods were removed. This includes: attachChildView, hasChildViews, getChildViews, getChildView, disposeChildViews, deactivateChildViews, detachChildViews, activateChildViews, registerChildView, unregisterChildView, unregisterChildViews.

Now, you can use "Tracked" versions of these methods: hasTrackedViews, getTrackedViews, etc.

Exceptions are: disposeChildViews which went private: __disposeChildViews, attachChildView is instead attachView without "tracked", and as mentioned in bullet 6, activateTrackedViews and deactivateTrackedViews were made private.

Calling these methods without passing in an argument, will perform the method on all tracked views (shared and child). You can pass in {shared: true} or {child: true} to limit the trypes of tracked views the method uses.

Render Updates:

  1. render method provides a prerender and postrender callback hooks that are invoked before and after the render process, respectively.
  2. render triggers events throughout the rendering process. These include:
    render:begin - which happens before the process starts, render:before-dom-update - which happens after prerender callback but before the DOM is updated, render:after-dom-update - which happens after the dom was updated but before delegation of events, render:after-delegate-events - which happens after delegate events but before the tracked views are attached or postrender callback, and finally render:complete - which happens after the process is complete.
  3. render invokes attachTrackedViews callback that developers can override to provide the logic of attaching tracked views into injection sites.
  4. attachTo no longer calls render then replaces itself with the injection site, calls delegateEvents and finally handles attach logic. Instead it sets up a "pending attach" and invokes a single re-render. During the render process, the view will replace itself with the pending injection site after the DOM is updated but before the delegation of events. Then after the render is completed, the attach callback logic is performed. This prevents inefficiencies with the previous method and utilizes the render's control of dom, events, lifecycles, and child views.

Transitions

Transitions were added with v0.5.0. The updates allow developers to specify a transitionOut and a transitionIn for a View and use these methods to augment the attach/detach process.

  1. transitionIn is a method you can specify on a View. This method takes in as arguments: attach, done, and options. Invoke the attach callback argument to add your view to the DOM during your transition in process. When the transition is complete, invoke the done argument callback. The options arguments contain information about the transition, the view being transitioned out, and the parent view.
  2. transitionOut is a method you can specify on a View. This method takes in as arguments: done, and options. Invoke the this.detach() to remove your view from the DOM during your transition out process. When the transition is complete, invoke the done argument callback. The options arguments contain information about the transition, the view being transitioned out, and the parent view.
  3. attachView now takes in a useTransition field in the options argument. If this is set to true, the view being attached will instead be transitioned in using its transitionIn method. Any view that is already in the injection site that matches the one you are attaching to will be transitioned out using its transitionOut. If the view being attached was the view in that injection site before (as happens during back-to-back renders), then the view is attached normally and no transitions are used.
  4. attachView now returns a promise that resolves when the view being attached is fully attached.
  5. You can return a promise or a list of promises when defining attachTrackedViews that resolve when the process of attaching your tracked views complete. Typically, this means capturing the promises returned by attachView during transitions and returning them.
  6. render now returns a promise that resolves when attachTrackedViews promise(s) resolves.