Coder Social home page Coder Social logo

reactor#unobserve about nuclear-js HOT 10 CLOSED

optimizely avatar optimizely commented on August 29, 2024
reactor#unobserve

from nuclear-js.

Comments (10)

jordangarcia avatar jordangarcia commented on August 29, 2024

Would it be by reference of the handler or the getter?

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

I was thinking with no arguments removes all handlers, and specific handlers can be removed by providing combinations of getters and handler function names.

reactor.unobserve() // no more observations for the entire reactor instance
reactor.unobserve(['some', 'keypath']) // no more observations on keypath changes
reactor.unobserve(someGetter) // no more observations on getter and/or ancestor changes
reactor.unobserve(someGetter, myHandler) // no more calls to myHandler 

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

the api seems pretty sane. I dont quite see the use case for doing a complete reactor.unobserve where you wouldn't want to do an entire reactor.reset()

I could see the use for using it by getter or getter + handler. Have you been running into cases where you find yourself wanting this functionality?

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

Fair point on reset. I can't think of a use case for unobserving without reseting either.

For the most part we've limited our overall use of observe, preferring to do things through actions. However, we do have a logging module and an analytics module, and those use observe to do things based on app state changes.

It's not often, but sometimes, state changes in a way that means we don't want to (permissions, etc.) log/track anymore. In these case we perform cleanup of observers by keeping a set of maps, each with a mapping to the unwatch function, then looping over the set. Being able to call unobserve on a particular keypath or getter, would be more terse and elegant IMO.

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

@colindresj I am pretty busy with the NuclearJS doc sites. If you want to implement this functionality you are more than welcome to.

from nuclear-js.

colindresj avatar colindresj commented on August 29, 2024

Cool, I'll get a PR ready for this soon. Let me know if you need help on the docs site — would be happy to help.

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

@colindresj - would love help on the docs site. lets chat soon

from nuclear-js.

jordangarcia avatar jordangarcia commented on August 29, 2024

Also doing everything in react + Nuclear, been really fun so far.

from nuclear-js.

rattrayalex avatar rattrayalex commented on August 29, 2024

I'm also interested in helping with the docs. Finally have started being able to use Nuclear at work =)

from nuclear-js.

bhamodi avatar bhamodi commented on August 29, 2024

Done in v1.2.0.

from nuclear-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.