Giter VIP home page Giter VIP logo

Comments (5)

ReedCopsey avatar ReedCopsey commented on July 20, 2024

No. At one point, I had implemented something similar, but it tends to lead to issues, so I decided to abandon it. Specifically, this tended to break the weak referencing schemes that I currently use, though I do think it could be done.

I've found that it's often conceptually nicer to have "mutations" back to the source work through a separate channel (such as using observable streams to push back changes).

What is the use case or need here? There may be an easy way to do it, or I could be convinced to implement this.

from gjallarhorn.

varon avatar varon commented on July 20, 2024

A use case for mine is this:
Say we had a value stored on the disk, in some human-readable format.
This has an in-memory representation of type A.
value of type B is created in a linked manner from the value.

Now we have two cases where we would want to propagate:

  • if (B) is updated, the disk-backing value should also change (A).
  • if the disk-backing value is changed, then B should reflect this.

The trick is using the library makes this largely transparent, provided the mapping is set up correctly.

Hopefully that's a bit more clear?

from gjallarhorn.

ReedCopsey avatar ReedCopsey commented on July 20, 2024

Yes - there's a lot of complexity around the edges when trying to do this correctly, which was part of why I abandoned it.

Currently, the approach we use in the framework built on top of Gjallarhorn would be to have a signal mapping from B (on disk) to A. Instead of mutating A, you'd create some message to update B, which causes the update and is immediately reflected again in A. The library makes this fairly easy to do - and it keeps things very clean.

from gjallarhorn.

varon avatar varon commented on July 20, 2024

Thanks for the super prompt answers. Yeah, I use graph painting to do the propagations properly.

Can you show an example of how this code would look.
How do you avoid cyclic propagations?

from gjallarhorn.

ReedCopsey avatar ReedCopsey commented on July 20, 2024

Can you show an example of how this code would look.
Take a look at some of the UI framework samples - https://github.com/ReedCopsey/Gjallarhorn.Bindable/blob/master/samples/ElmInspiredOne/ElmInspiredOne/Program.fs

That should give you an idea of the basic concept. You can drill into it, or if you need it, I'd be happy to discuss how the "guts" of it work, but it's fairly simple to setup.

How do you avoid cyclic propagations?

Effectively, propogation is only one way - "edits" on the front (A) are sent as messages to update the backend (B) , and don't actually change A. A then automatically gets the new value reflected. Signals, in the default implementation, only propagate changes if the value itself changes, so cyclic issues don't happen.

from gjallarhorn.

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.