emberjs-addons / sproutcore-statechart

(Ember Only) Repository for the ported SproutCore Statechart package
www.sproutcore.com
50 stars 11 forks source link

Adds support for sproutcore-routing to statechart framework #16

Closed DominikGuzei closed 12 years ago

DominikGuzei commented 12 years ago

This pull request includes the support for sproutcore-routing taken from the 1.x sproutcore repository which was authored and tested by Michael Cohen. Since Sproutcore 2.0 is now officially called Ember.js and has introduces its own best practices regarding repository structure and testing, the sproutcore-statechart package has been renamed to ember-statechart and ruby is used to build and run the unit tests. The routing support for ember-statechart has been slightly improved by introducing a better algorithm for choosing a current state to transition from when responding to a change of routes.

I know, that's a lot of changes for one pull request, and not everything is covered with unit tests yet - but all previous unit tests pass successfully. So I think it's a useful start for improvements and better test coverage.

ebryn commented 12 years ago

I don't think renaming SC 1.x projects as ember- makes sense.

I'd love to see your updates submitted without the rename.

DominikGuzei commented 12 years ago

Ok, I thought the renaming of sproutcore 2.0 was a goal and it would make more sense if some day all addons are renamed to the ember namespace too? I mean, is there any official opinion about that? But anyway - it's no big deal, will open a new pull request without the rename!

ebryn commented 12 years ago

The official opinion is that only supported packages should be renamed. That's why most of the emberjs-addons repos are still named sproutcore-.

DominikGuzei commented 12 years ago

Ok thanks for the clarification ebryn! ;-) I renamed the package to sproutcore-statechart and checked that build script and unit tests still work!

FrozenCanuck commented 12 years ago

Thanks Dominik for doing this. Glad to know that people who use Ember.js can now take advantage of statechart routing support just like in SproutCore :)

DominikGuzei commented 12 years ago

You're welcome Michael - I'm also building an example application at the moment to testdrive these new features. It could become a good starting point to learn about the capabilities of sproutcore-statechart in Ember.js

FrozenCanuck commented 12 years ago

Yes, definitely. I look forward to your progress on your test app. In addition, I need to find some time to publish a blog post on the new statechart routing feature -- I've just been too swamped with other things :P

grayrest commented 12 years ago

As someone who's been mostly spectating on the statecharts, I'm somewhat confused on how ember is doing statechart support. I was under the impression that the Tilde guys had a version in core that interacted with templates and would replace this one.

For the example app, the other bit of information that isn't clear in my mind is how to handle asynchronous state transitions. As an example, I want a state for when an overlay is visible but then the designer wants it to animate in/out. An example of how to do this or some other asynchronous behavior as part of the example app would be nice.

Sorry for hijacking the pull request, but I've been wondering about these two points for two months or so.

FrozenCanuck commented 12 years ago

@grayrest

I can't speak directly to what Tom and Yehuda are doing with the other statechart-like framework; however I can answer your questions regarding asynchronous state transitions :).

You can indeed perform asynchronous state transition with this version of the statechart framework the same way you do an asynchronous state transition that comes with the statechart framework in SproutCore: By making use of the SC.Async.perform command. (You can read about the command here: https://github.com/emberjs-addons/sproutcore-statechart/blob/master/lib/system/async.js). Once your enterState/exitState method returns an async, your code will then eventually need to resume the state transition process by calling the statechart's resumeGotoState method. You can always check if the state transition process is suspended by checking the statechart's gotoStateSuspended method.

ebryn commented 12 years ago

Thanks @DominikGuzei for the update. I assume since @FrozenCanuck approves that things look in order :)