Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Adds support for sproutcore-routing to statechart framework #16

Merged
merged 9 commits into from

4 participants

@DominikGuzei

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.

Dominik Guzei added some commits
Dominik Guzei Adds routing support for statechart framework a8e16bd
Dominik Guzei Fixes type checks from sproutcore 1.x fe45dc2
Dominik Guzei Improves gotoState algorithm for choosing fromState
When using the routing system in combination with concurrent states it lead to problems at transitions. The previous algorithm just looked up current substates and if there were none, it used a null state. Now we walk up the state tree to find the nearest parent/ancestor current state in the tree.
e8d7b5b
Dominik Guzei Refactors packaging structure to use rackup qunit testing
The Ember.js repository uses rackup to serve unit tests. This approach also seems to be the accepted new way of providing tested emberjs-addons.
dfb99ca
Dominik Guzei Renames distribution to ember-statechart and fixes tests/build
Since Sproutcore 2.0 is now officially Ember.js the name of the distribution and package was changed to ember-statechart.
fea363d
Dominik Guzei Adds unit test for SC.StateRouteHandlerContext.retry 0fdd892
Dominik Guzei Adds unit test for route triggered on states
This unit test is taken from the 1.x sproutcore repository and was created by Michael Cohen (FrozenCanuck)
9c46370
Dominik Guzei Updates readme for better understanding of the changes c0a5cfb
@ebryn
Owner

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

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
Owner

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

Dominik Guzei Renames ember-statechart package back to sproutcore-statechart
Since Ebryn complained about the renaming of 1.x sproutcore addons this commit reverses the renaming but keeps unit tests and build script working.
577881e
@DominikGuzei

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

@FrozenCanuck

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

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

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

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

@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 ebryn merged commit e57e47d into from
@ebryn
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 29, 2012
  1. Adds routing support for statechart framework

    Dominik Guzei authored
Commits on Jan 30, 2012
  1. Fixes type checks from sproutcore 1.x

    Dominik Guzei authored
  2. Improves gotoState algorithm for choosing fromState

    Dominik Guzei authored
    When using the routing system in combination with concurrent states it lead to problems at transitions. The previous algorithm just looked up current substates and if there were none, it used a null state. Now we walk up the state tree to find the nearest parent/ancestor current state in the tree.
  3. Refactors packaging structure to use rackup qunit testing

    Dominik Guzei authored
    The Ember.js repository uses rackup to serve unit tests. This approach also seems to be the accepted new way of providing tested emberjs-addons.
  4. Renames distribution to ember-statechart and fixes tests/build

    Dominik Guzei authored
    Since Sproutcore 2.0 is now officially Ember.js the name of the distribution and package was changed to ember-statechart.
  5. Adds unit test for SC.StateRouteHandlerContext.retry

    Dominik Guzei authored
Commits on Jan 31, 2012
  1. Adds unit test for route triggered on states

    Dominik Guzei authored
    This unit test is taken from the 1.x sproutcore repository and was created by Michael Cohen (FrozenCanuck)
  2. Updates readme for better understanding of the changes

    Dominik Guzei authored
  3. Renames ember-statechart package back to sproutcore-statechart

    Dominik Guzei authored
    Since Ebryn complained about the renaming of 1.x sproutcore addons this commit reverses the renaming but keeps unit tests and build script working.
Something went wrong with that request. Please try again.