-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why Seed doesn't use a traits for the models #310
Comments
My opinion: You have to define your When we would force app developers to use
How I'm writing Seed apps from scratch:
My background, so you know why I think like that: @MuhannadAlrusayni I've written my reasoning behind that design decision, but I'm happy that you want to break status quo. Maybe you are right and it would make Seed apps simpler and less error-prone. If we want to continue with the discussion, I suggest to create a bigger example with nested components so we can compare current and proposed API and architecture properly. Then, if that example would look promising, we would need to rewrite at least real-world example and quickstart-with-webpack. After that there will be a chance to merge it into the Other opinions or ideas? |
Well, this depends on the developer, even in the current Seed implementation that can happen.
This issue would arise if we have one trait say But with the traits I mentioned earlier (
This might be true for app developer's point of view. But from library developer point of view, they would have hard time to make a unified API, and would be impossible to use 3rd-partiy libraries unless they hard code them. But using traits would make our code works with any type that implement these traits, even types that don't exist yet!.
I tried to understand your example, sorry but I couldn't understand how things work in it :D, it would be cool if you make simplified version of the things you're trying to show me.
This workflow is doable with traits approach too.
I agree that not every object should be component/model, some are
Sure I was experimenting with these two traits in the past 4-5 weeks, and I |
It looks like the real question isn't "Why Seed doesn't use traits for the models?" but "How to write a library for Seed / in Elm architecture?". |
Yeah, you're right, I found that using traits is one of the simplest ways to write libraries for Seed, that's why I asked. |
@MuhannadAlrusayni see #111 I'm closing this issue because I hope I answered the original question and we can reopen it once something important (e.g. Seed API) is changed. |
Hi, Why Seed doesn't use a traits for the models ?
In another way, why Seed doesn't have trait(s) that every model must implement? I think this would simplify the way we create and use models..
First, I thought that Seed uses functions for the flexibility so that every model chose how to call it's view and update method, thus Seed doesn't restrict the model API.
But I have tried to use traits to see if there are any blocking limitation that would block Seed from using traits and I didn't find any of that. I actually found it more convenient to call
model.view()
ormodel.update(msg, orders)
for any model so I don't need to know how construct the model or what args the view method needed to view the model (these should be handled else where, "decoupling").Here is the traits I use:
We can write bounds for
view/model
s this way:Using traits makes writing macros for
Model/View
s easier task, since macros would easily callview()
orupdate()
following the trait functions signatures.It would also make
App
andAppBuilder
API more friendly and simple:Traits would be good to have if we want to make reusable
View/Model
s libraries, so that these libraries have a unified API to update or view models.Traits with a simple functions would make
View/Model
s easy to learn and use.Some other frameworks do have trait that does similar thing (e.g.
Component
,Model
..etc)I am not sure if there is a disadvantage of using traits, the only thing I can see is that trait functions can't return
impl View
, but that is not really a blocker.This is open talk, share your thoughts. :D
The text was updated successfully, but these errors were encountered: