ampersandjs.com icon indicating copy to clipboard operation
ampersandjs.com copied to clipboard

Critical: view.props is missing in docs

Open jrmyio opened this issue 10 years ago • 3 comments

Wow, i was completely unaware views can hold props/derived too. That changes the way you build your models a lot!

I think it should be added to the docs asap!

(I'm unaware if "session" is supported too)

jrmyio avatar Aug 13 '14 22:08 jrmyio

I don't think the props in view are technically supported. There are things in the view that needed to be stateful, so view extends state and has custom types for element and collection.

What kind of other properties are you finding that you need to store in the view?

wraithgar avatar Aug 16 '14 04:08 wraithgar

@wraithgar They're intentionally supported. See the form views for good examples of extra view state. Basically any type of widget view will want these.

I vaguely recall convincing Henrik that this sort of behaviour was needed so that I could publish standalone Ampersand models (say a chat message model), and use (derived) view properties to adapt those models to the view's needs.

legastero avatar Aug 16 '14 05:08 legastero

Yup views are based on state too. Good point on the docs. Props, session and derived all work. In fact that's how it knows when rendered or not. It has a prop for el.

HenrikJoreteg avatar Aug 16 '14 05:08 HenrikJoreteg