File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,11 @@ export abstract class DynamicComponentClass {
2727 }
2828
2929 protected _variable ( key : string ) : any {
30- return this [ key ] ;
30+ if ( key . length > 0 ) {
31+ return this [ key ] ;
32+ } else {
33+ throw new Error ( `DynamicComponentClass._variable(key) : key length is 0` ) ;
34+ }
3135 }
3236
3337 // create component in container
@@ -38,7 +42,7 @@ export abstract class DynamicComponentClass {
3842 return this ;
3943 }
4044
41- // destroy component
45+ // destroy component if exist
4246 protected _destroy ( ) : null {
4347 if ( this . _component ) {
4448 this . _component . destroy ( ) ;
@@ -76,17 +80,14 @@ export abstract class DynamicComponentClass {
7680 /**
7781 * Subscribe to created component instance @Output
7882 * @param key instance variable of created component
79- * @param callback function initiated in subscribe
83+ * @param args initiated in subscribe
8084 */
81- protected _subscribe ( key : string , callback ?: Function ) : this {
85+ protected _subscribe ( key : string , ... args : any [ ] ) : this {
8286 // if created component has got property to subscribe
8387 if ( this . _component . instance . hasOwnProperty ( key ) ) {
84- this . _component . instance [ key ] . subscribe ( ( result : any ) => {
85- // callback
86- if ( callback ) {
87- callback ( result ) ;
88- }
89- } ) ;
88+ this . _component . instance [ key ] . subscribe ( ...args ) ;
89+ } else {
90+ throw new Error ( `this._component.instance does not have property ${ key } ` ) ;
9091 }
9192 return this ;
9293 }
You can’t perform that action at this time.
0 commit comments