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
While this works very nicely already, it's cumbersome to re-type the type twice, so I made a little helper here.
Solution
// Declare the wrapper for the input valuetypeRxInput<T>=Observable<T>|T;// Decalre this function to route the connectfunctionrxConnectInput<TStateextendsobject,TStateKeyextendskeyofTState>(state: RxState<TState>,key: TStateKey,value: RxInput<TState[TStateKey]>){state.connect(key,coerceObservable(value));}// This should be done inside the wrapping class, obviously, but for sake of simplicity, I'm writting like this.conststate=rxState<{someStringInput: string}(({ set })=>{set({someStringInput: 'Initial value'});});
@Input()setsomeStringInput(value: RxInput<string>){rxConnectInput(this.state,'someStringInput',value);}
My idea here is just to make things a little bit less boilerplate and more direct to the point, it's working fine here and fully tested.
Renato
The text was updated successfully, but these errors were encountered:
What about using @Input({ transform: coerceObservable }) value instead? This way there's less boilerplate, RxInput is not necessary anymore and you just have to call connect.
Hello,
I've just installed version 16, it's a hell of nice work, amazing job!
Problem Solved By The Feature
Right now, we could to pass inputs to components like it's described in the docs:
While this works very nicely already, it's cumbersome to re-type the type twice, so I made a little helper here.
Solution
My idea here is just to make things a little bit less boilerplate and more direct to the point, it's working fine here and fully tested.
Renato
The text was updated successfully, but these errors were encountered: