Coder Social home page Coder Social logo

Comments (1)

dphfox avatar dphfox commented on June 11, 2024 2

I'm going to hijack this issue with a radical idea; what if we got rid of Observer entirely as a user-facing construct? Nobody actually uses them for anything except immediately piping it into an :onChange() or :onBind() call.

Things have changed a lot since 0.1 when this API surface was first introduced. Now that we have scopes, we've externalised all destruction tracking, so we can append code into the current scope to handle disconnecting the listener. Beyond that, what purpose does Observer as a public-facing construct serve?

So my proposition is this; drop the API entirely, and replace Observer with a function, observe() or onChange() or something like that. As far as the user cares, those functions connect the callback to be run in a new coroutine at some point soon after an update occurs. Maybe it also provides some nice options to track multiple state objects or run the callback immediately to match onBind - I don't know, but all that matters is there's no object involved.

Under the hood, Fusion can now internally manage whatever reactive graph mechanisms it needs in order to dispatch those listeners. Fusion can count the number of listeners so that it destroys whatever internal objects its using once all listeners are disconnected.

From there, observe() becomes the foundation atop which we can build other APIs, like perhaps a general connector for binding instances to properties, which can then be used in applyInstanceProps (#304)

from fusion.

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.