Skip to content Skip to sidebar Skip to footer

Remote Service In Aurelia Component Lifecycle

I'm trying to figure out at what point of the component lifecycle do I call into a remote service? I'm looking to create components that are tied to a remote service so instead of

Solution 1:

Use the attached callback. When a viewmodel has an attached method, aurelia will call it after the view has been added to the DOM. Alternatively you could use the bind callback. It's a bit earlier in the lifecycle than attached and is called after the component has been data-bound (but is not yet attached to the DOM).

Use the detached or unbind methods to cleanup/unsubscribe/cancel any async processes or subscriptions you might have made in attached or bind.

created(view) >> bind(bindingContext) >> attached() >> detached() >> unbind()

Post a Comment for "Remote Service In Aurelia Component Lifecycle"