You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This requires accessing the options property of the app instance to retrieve the methods from another app:
constBazComponent=observe(app=>streamProps().set({foo: app.get('foo').options.bar,// retrieve `bar` method out of `foo` app options}).get$())(({ bar })=>/* `bar` method as prop */)constBazApp=createApp({name: 'Baz',providers: [{name: 'component',useValue: BazComponent,},{name: 'foo',deps: ['rootApp'],useFactory({ rootApp }){returnrootApp.getAppInstance('Foo')}}]})
Proposal
Add a new, optional methods (Object) property to the options argument of createApp, which has its properties added to the app's this object, thus allowing us to access the methods directly from the app instance:
constFooApp=createApp({name: 'Foo',methods: {// specify what methods this app exposesbar(){console.log('bar')}}})
constBazComponent=observe(app=>streamProps().set({foo: app.get('foo').bar,// retrieve `bar` method out of `foo` app directly}).get$())(({ bar })=>/* `bar` method as prop */)constBazApp=createApp({name: 'Baz',providers: [{name: 'component',useValue: BazComponent,},{name: 'foo',deps: ['rootApp'],useFactory({ rootApp }){returnrootApp.getAppInstance('Foo')}}]})
The text was updated successfully, but these errors were encountered:
Currently
We can declare methods inside
createApp
to expose application-specific behavior:This requires accessing the
options
property of the app instance to retrieve the methods from another app:Proposal
Add a new, optional
methods
(Object
) property to theoptions
argument ofcreateApp
, which has its properties added to the app'sthis
object, thus allowing us to access the methods directly from the app instance:The text was updated successfully, but these errors were encountered: