AmpersandJS / ampersand-state

Core state management object.
MIT License
141 stars 75 forks source link

Fixing inconsistent collection behavior #254 #255

Closed bryanspears closed 3 years ago

dhritzkiv commented 7 years ago

I wonder if null should be rejected (throw) as an initial value for states.

In any case, I'll try to review this PR this weekend.

bryanspears commented 7 years ago

I don't think ampersand-state should define how ampersand-collection initializes. Collection is just another type, but unlike other simple types (e.g. 'string' and 'number') it defines its own get/set methods and more. Throwing an error based on dynamic data could be a problem.

My thought is when new Collection() is executed it should always result in a valid, working collection object. Especially since it can be a child of a State object. Which means it needs to be more forgiving in all the null, undefined, or other situations and just initialize with [].