v0.5.0
A number of breaking changes and API updates were introduced with v0.5.0, all of which occured in View.js
Breaking Changes:
render
method should no longer be overridden. If you are attaching child views, move that logic into a method namedattachTrackedViews
. If you were doing custom logic in your render method, consider moving it intoprerender
that happens before the render logic, or intopostrender
that happens after all the rendering is complete.unplug
andplug
were renamed toprerender
andpostrender
respectively and are always called byrender
attach
method was renamed toattachTo
injectView
was removed. UseattachView
which now takes an injection site name string or an element as the first parameter. This totally encompased the usefulness ofinjectView
so it was removed.invokeAttached
andinvokeDetached
were made private:__invokeAttached
and__invokeDetached
activateTrackedViews
anddeactivateTrackedViews
were made private:__activateTrackedViews
and__deactivateTrackedViews
- #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:
render
method provides aprerender
andpostrender
callback hooks that are invoked before and after the render process, respectively.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 finallyrender:complete
- which happens after the process is complete.render
invokesattachTrackedViews
callback that developers can override to provide the logic of attaching tracked views into injection sites.attachTo
no longer callsrender
then replaces itself with the injection site, callsdelegateEvents
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.
transitionIn
is a method you can specify on a View. This method takes in as arguments:attach
,done
, andoptions
. Invoke theattach
callback argument to add your view to the DOM during your transition in process. When the transition is complete, invoke thedone
argument callback. Theoptions
arguments contain information about the transition, the view being transitioned out, and the parent view.transitionOut
is a method you can specify on a View. This method takes in as arguments:done
, andoptions
. Invoke thethis.detach()
to remove your view from the DOM during your transition out process. When the transition is complete, invoke thedone
argument callback. Theoptions
arguments contain information about the transition, the view being transitioned out, and the parent view.attachView
now takes in auseTransition
field in theoptions
argument. If this is set to true, the view being attached will instead be transitioned in using itstransitionIn
method. Any view that is already in the injection site that matches the one you are attaching to will be transitioned out using itstransitionOut
. 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.attachView
now returns a promise that resolves when the view being attached is fully attached.- 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 byattachView
during transitions and returning them. render
now returns a promise that resolves whenattachTrackedViews
promise(s) resolves.