reef icon indicating copy to clipboard operation
reef copied to clipboard

Add component.destroy() method

Open cferdinandi opened this issue 3 years ago • 1 comments

Stops auto rending and wipes DOM clean

cferdinandi avatar Jul 17 '22 03:07 cferdinandi

I'd love to see this! I was thinking about implementing something like an usubscribe method, where you'd detach from processing state changes but keep the component html on page.

I was also considering implementing a "when" utility function (similar to mobx when) which would allow a one-and-done reaction to a change on a store that matches the condition, and then stops listenting. Could also be implemented as a method on the store itself.

It would also be great to have a "reaction" utility function (again, similar to mobx here), which would allow you to react to stores without having a component. Many use cases for reactivity don't result in UI re-renders, but actually in just firing some side-effect. Is there currently a way to fire arbitrary side effects from store changes?

This is a really cool project, appreciate your work here, and I love the direction you went in v12.

t-lock avatar Aug 16 '22 13:08 t-lock

@t-lock Apologies for being a year late to respond to this one. The things you're asking about are actually already supported in Reef.

cferdinandi avatar Jun 24 '23 16:06 cferdinandi

The even listener will also allow you to fire side-effects without rendering

cferdinandi avatar Jun 24 '23 16:06 cferdinandi