Raynos / mercury

A truly modular frontend framework
http://raynos.github.io/mercury/
MIT License
2.82k stars 143 forks source link

Rendering subitems of different types #213

Closed RubenVerborgh closed 8 years ago

RubenVerborgh commented 8 years ago

In the TodoMVC example, the app needs to know how todo items are rendered. This works in the case of TodoMVC, where all elements are uniform, but it is more complex if a list can contain items of different types.

What would be best practice to avoid the dependency of a parent on the type of its children?

Raynos commented 8 years ago

@RubenVerborgh

Create a higher order render function, renderListContainer(renderItem, { ... })

RubenVerborgh commented 8 years ago

But that would then contain a switch statement or similar, right?

Would it make sense to somehow attach the render function to the state?

(I'm very new to mercury; my urge is to call item.render with a render defined on the prototype, but prototypes don't really apply.)

Raynos commented 8 years ago

If it works then do it :D mercury has flexibility.

RubenVerborgh commented 8 years ago

Fair enough 😄

Make things a bit more messy than I'd like, but manageable.