Adding a generic type parameter for using's resource #6497
Replies: 1 comment 1 reply
-
I suspect that It would make sense to use an additional type parameter, but I'd be inclined to go further an add an overload so that the export function using<T extends ObservableInput<any>, R extends Unsubscribable>(
resourceFactory: () => R,
observableFactory: (resource: R) => T | void
): Observable<ObservedValueOf<T>>;
export function using<T extends ObservableInput<any>>(
resourceFactory: () => void,
observableFactory: () => T | void
): Observable<ObservedValueOf<T>>; IDK why the Because this changes the type parameters, I don't think this change could be incorporated in version 7, but it could be made in version 8. If you want to open a PR with these changes, please do. Although, it will be labelled as v8 and won't be merged for some time. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
using
has the following signature:This signature means my observableFactory needs to cast its parameter to the actual type:
Is there any reason not to change the signature like so?
I tried making this change and it seems to work, but there could be a backwards compatibility reason not to change this.
Beta Was this translation helpful? Give feedback.
All reactions