Code Monkey home page Code Monkey logo

Comments (3)

alexmingoia avatar alexmingoia commented on June 2, 2024

I don't know why Elm and subsequently purescript-signal settled on this behaviour

It's the only behavior possible. A signal only has one value at any point in time. Signal a -> Signal a -> Signal a can't return Signal (List a), so one value must be chosen. Conceptually, a Pux app has one signal of actions and signal values/actions only "occur" discretely one-at-a-time.

If you need an initial route, window dimension, and time, then you set those in your initialState. There's no need for actions to control initial state. This could be documented better - I'll add it to the roadmap

from purescript-pux.

menelaos avatar menelaos commented on June 2, 2024

It's the only behavior possible. A signal only has one value at any point
in time. Signal a -> Signal a -> Signal a can't return List a, so one
value must be chosen. Conceptually, a Pux app has one signal of actions
and actions only occur discretely one-at-a-time.

Sorry, if I wasn't clear on this. I'm not suggesting for merge to return a List a as that would be impossible, like you said. Rather, I would (naively?) expect merge to behave similar to the merge from RxJS which never discards a value but instead emits them one after the other.

It seems that some people in the Elm community have been tripped up by this behaviour, too.
The fairMerge function was written to address exactly this issue, though it has not been officially endorsed (yet?).

If you need an initial route, window dimension, and time, then you set
those in your initialState. This could be documented better - I'll add
it to the roadmap

Cool, thanks.

from purescript-pux.

jgoux avatar jgoux commented on June 2, 2024

I just had a similar issue, I needed the current route to initialize the whole app.
I passed it manually from JS to the initialState as suggested by @alexmingoia :

var Main = require('../src/Main.purs');
var initialState = require('../src/Application.purs').init;
var debug = process.env.NODE_ENV === 'development'
var currentUrl = window.location.pathname + window.location.search

if (module.hot) {
    var app = Main[debug ? 'debug' : 'main'](window.puxLastState || initialState(currentUrl))();
    app.state.subscribe(function (state) {
     window.puxLastState = state;
    });
    module.hot.accept();
} else {
    Main[debug ? 'debug' : 'main'](initialState(currentUrl))();
}

from purescript-pux.

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.