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:
rendermethod 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 intoprerenderthat happens before the render logic, or intopostrenderthat happens after all the rendering is complete.unplugandplugwere renamed toprerenderandpostrenderrespectively and are always called byrenderattachmethod was renamed toattachToinjectViewwas removed. UseattachViewwhich now takes an injection site name string or an element as the first parameter. This totally encompased the usefulness ofinjectViewso it was removed.invokeAttachedandinvokeDetachedwere made private:__invokeAttachedand__invokeDetachedactivateTrackedViewsanddeactivateTrackedViewswere made private:__activateTrackedViewsand__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:
rendermethod provides aprerenderandpostrendercallback hooks that are invoked before and after the render process, respectively.rendertriggers 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.renderinvokesattachTrackedViewscallback that developers can override to provide the logic of attaching tracked views into injection sites.attachTono longer callsrenderthen replaces itself with the injection site, callsdelegateEventsand 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.
transitionInis a method you can specify on a View. This method takes in as arguments:attach,done, andoptions. Invoke theattachcallback argument to add your view to the DOM during your transition in process. When the transition is complete, invoke thedoneargument callback. Theoptionsarguments contain information about the transition, the view being transitioned out, and the parent view.transitionOutis 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 thedoneargument callback. Theoptionsarguments contain information about the transition, the view being transitioned out, and the parent view.attachViewnow takes in auseTransitionfield in theoptionsargument. If this is set to true, the view being attached will instead be transitioned in using itstransitionInmethod. 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.attachViewnow 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
attachTrackedViewsthat resolve when the process of attaching your tracked views complete. Typically, this means capturing the promises returned byattachViewduring transitions and returning them. rendernow returns a promise that resolves whenattachTrackedViewspromise(s) resolves.