Allow users of a viewModelFactory to create subscriptions in the function, and unsub when the
component unmounts. This should prevent memory leaks when a user creates a subscription in a viewModelFactory.
Implementation
Add an optional unsubscribe list to the ViewModel type
On unmount, unsubscribe to all items in the list
Add a test showing that the unsubscribe happens at the right time
For discussion
Unrelated, but when getting the project going, I had to go back to Node 6 (which to be fair is what's listed in the package.json) to prevent some node-gyp error.
I'm also getting a typescript error from WrappedComponent even on master:
Type 'Readonly<S> & ActionMap<A> & Readonly<{ children?: ReactNode; }> & Readonly<Pick<T, Exclude<keyof T, keyof S | keyof A>> & P>' is not assignable to type 'IntrinsicAttributes & T & { children?: ReactNode; }'.
Type 'Readonly<S> & ActionMap<A> & Readonly<{ children?: ReactNode; }> & Readonly<Pick<T, Exclude<keyof T, keyof S | keyof A>> & P>' is not assignable to type 'T'.
'Readonly<S> & ActionMap<A> & Readonly<{ children?: ReactNode; }> & Readonly<Pick<T, Exclude<keyof T, keyof S | keyof A>> & P>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'ActionMap<A>'
Goals
Allow users of a viewModelFactory to create subscriptions in the function, and unsub when the component unmounts. This should prevent memory leaks when a user creates a subscription in a viewModelFactory.
Implementation
unsubscribe
list to the ViewModel typeFor discussion
Unrelated, but when getting the project going, I had to go back to Node 6 (which to be fair is what's listed in the package.json) to prevent some node-gyp error.
I'm also getting a typescript error from
WrappedComponent
even on master: