Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Add state new usage for following example. - #5

Open
zw963 wants to merge 1 commit into
ruby-hyperloop:masterfrom
zw963:master
Open

Add state new usage for following example.#5
zw963 wants to merge 1 commit into
ruby-hyperloop:masterfrom
zw963:master

Conversation

@zw963

Copy link
Copy Markdown

Personal think following more intuitive for a declare statement like syntax.
e.g.
state :state_name, 'initial value'
state :state_name, 'initial value', class: true

Personal think following more intuitive for a declare statement like syntax.
e.g.
state :state_name, 'initial value'
state :state_name, 'initial value', class: true

@catmandocatmando left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you add some test cases you will see that this does not always work.

All these cases should work:

state:foo# will be initialized to nilstatefoo: 12# will be initialized to 12state:foo,12# will be initialized to 12 alsostatefoo: 12,scope: :classstate:foo,12,scope: :classstate:foo,{}# foo is initialized to nil, and there are no optionsstate:foo,{},{}# foo is initialized to {} and there are no options

The thing that makes it tricky is that the last 2 cases.

Advice is to write test cases now...

@catmando

Copy link
Copy Markdown
Contributor

Lets keep the discussion on this change here (rather than in the gitter chat)

There is too much code out in the wild depending on the current structure to change it.

Besides I think most dev's find the structure natural.

Finally as far as initialization to nil, this is standard ruby. State variables are just like instance variables that cause rerendering when changed. Instance variables by default initialize to nil, and so do state variables.

So I am fine with adding your syntax, but you are going to have to parse it so that both old and new style work.

@zw963

Copy link
Copy Markdown
Author

@catmando , Thanks for reply.

After read some post write by you in quora, and Comparing-Redux-with-Hyperloop, I think current usage not so unreasonable.

Though I still hope add new state usage to project, But, as I say previous in gitter, current,
If I If i did not make a mistake, it seem like we have no idea to distinguish following usage,
right?

state:one_hash_state,scope: class,reader: allstate:one_hash_state,{scope: class},scope: class# {scope: class} is state default value

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@zw963@catmando