File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -511,4 +511,35 @@ describe('frint › App', function () {
511511 const app = new Root ( ) ;
512512 expect ( app . get ( 'foo' ) ) . to . equal ( 'original foo [updated]' ) ;
513513 } ) ;
514+
515+ it ( 'can access and update providers from lifecycle callback defined while instantiating' , function ( ) {
516+ const Root = createApp ( {
517+ name : 'RootApp' ,
518+ providers : [
519+ {
520+ name : 'foo' ,
521+ useValue : 'original foo' ,
522+ } ,
523+ ] ,
524+ initialize ( ) {
525+ const foo = this . get ( 'foo' ) ;
526+ this . container . register ( {
527+ name : 'foo' ,
528+ useValue : `${ foo } [updatedFromCreateApp]` ,
529+ } ) ;
530+ }
531+ } ) ;
532+
533+ const app = new Root ( {
534+ initialize ( ) {
535+ const foo = this . get ( 'foo' ) ;
536+ this . container . register ( {
537+ name : 'foo' ,
538+ useValue : `${ foo } [updatedFromInstantiation]` ,
539+ } ) ;
540+ }
541+ } ) ;
542+
543+ expect ( app . get ( 'foo' ) ) . to . equal ( 'original foo [updatedFromCreateApp] [updatedFromInstantiation]' ) ;
544+ } ) ;
514545} ) ;
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ function mergeOptions(createAppOptions, constructorOptions) {
1616 typeof constructorOptions [ cbName ] === 'function'
1717 ) {
1818 mergedOptions [ cbName ] = function lifecycleCb ( ) {
19- createAppOptions [ cbName ] ( ) ;
20- constructorOptions [ cbName ] ( ) ;
19+ createAppOptions [ cbName ] . call ( this ) ;
20+ constructorOptions [ cbName ] . call ( this ) ;
2121 } ;
2222 }
2323 } ) ;
You can’t perform that action at this time.
0 commit comments