Code Monkey home page Code Monkey logo

Comments (18)

zaceno avatar zaceno commented on April 27, 2024 2

Vuex (Vue.js equivalent to msg) also uses a flat structure. The reasoning is, as far as I understand it, that there is no practical benefit to namespacing/nesting over simply prefixing as a strategy to avoid naming collisions.

That said, I also am curious about strategies (in general -- not just for the reducers/effects) for structuring and sensibly managing larger scale, complex apps (with potentially hundreds of reducers). All my experience with really big and complex apps is from the world of MVC, and in coming to this brave new world of the Elm-ish/React-ish paradigm, I have mostly been exposed to trivial examples and haven't found much in terms of composing larger apps from smaller pieces (like a SAM equivalent of H(ierarchical)MVC for example).

from hyperapp.

selfup avatar selfup commented on April 27, 2024 2
const red = require("./red-effects")
const blue = require("./blue-effects")
const yellow = require("./yellow-effects")

app({
  update: { red, blue, yellow }
})

Now there is no naming conflict but it is no longer flat 🤔

from hyperapp.

FlorianWendelborn avatar FlorianWendelborn commented on April 27, 2024 2

@selfup This is possible though:

app({
	update: {
		...red,
		...blue,
		...yellow
	}
})

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024 1

@jbucaran it makes, but there may be name collisions... That's the important thing.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024 1

choo solved this with namespaces IIRC.

I didn't like the idea of namespaces, so I didn't implement any.

What other options do we have?

from hyperapp.

FlorianWendelborn avatar FlorianWendelborn commented on April 27, 2024 1

@tunnckoCore We can talk about combining this with the solution for multiple models/components/etc. though.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024 1

Forgot to close here. This has been implemented by @dodekeract and it's available from 0.6.0 🎉!

Now, reducers and effects, can be used as usual or instead of a single object with functions, can also have arbitrarily nested objects with more functions. These functions can be on the same level as the namespace or above, or under. It's recursive in nature, so you can go crazy with this.

The object that holds all this data,actions is initialized only once, so there is no fear of this slowing us down, in fact, after this HyperApp became faster. From 1.40 down to 1.37.

See #75.

/cc @nichoth

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@dodekeract Interesting. Nope. I never considered this.

Sometimes because it's nice to have doesn't mean we should have it, but I am open to feedback.

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

Don't see value. It is better to be flat. But any use case, more real examples?

from hyperapp.

FlorianWendelborn avatar FlorianWendelborn commented on April 27, 2024

@tunnckoCore basically anything with lots of updates/effects. That way it'd be possible to split it into multiple files. It's also less tedious to prevent name clashes and easier to remember the names.

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

@dodekeract

const red = require("./red-effects")
const blue = require("./blue-effects")
const yellow = require("./yellow-effects")

app({
  update: Object.assign({}, red, blue, yellow)
})

Does that make sense?

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

choo solved this with namespaces IIRC.

Yes and no. Not exactly, or at least I think that they have the same problem in that case. There namespaces are for different models. Here we talk for one model.

from hyperapp.

tunnckoCore avatar tunnckoCore commented on April 27, 2024

@zaceno same here :) I was MVC a long ago, but still can get the Components thing really enough. But also don't have enough time and wish to review some big project using vue, react or whatever.

As about ELM-sh.. I really feel it easy and like it. Thanks to choo for very good README and intro to all that.

from hyperapp.

selfup avatar selfup commented on April 27, 2024

@dodekeract Ohh that is nice too

But then i wonder what happens if the same keys are present...which one does it call?

from hyperapp.

FlorianWendelborn avatar FlorianWendelborn commented on April 27, 2024

@selfup the last one. In this case the one from yellow.

from hyperapp.

selfup avatar selfup commented on April 27, 2024

Oh interesting! Good to know there is a fallback

from hyperapp.

jorgebucaran avatar jorgebucaran commented on April 27, 2024

Closing as I don't think I'll be implementing nested actions.

from hyperapp.

nichoth avatar nichoth commented on April 27, 2024

I ended up using the same nested interface in my project also to compose components, seems pretty good so far.

from hyperapp.

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.