Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

proxy.callbacks() are inconsistent when query is absolute vs resolved #28

Closed
bemson opened this Issue Mar 21, 2013 · 1 comment

Comments

Projects
None yet
1 participant
Owner

bemson commented Mar 21, 2013

The .callbacks() method of Flow instances returns a different function based on the string format. When the string matches the full path of an existing state, it returns that state's callback function. All other strings are assumed to be dynamic paths (to be resolved later), and returns an anonymous function.

A state's callback function is augmented to reference it's descendant state's callback functions - the rest of it's program tree. The anonymous function has no such structure appended to it.

Given the following flow...

var app = new Flow({
  here: {
    and: {
      there: {}
    }
  }
});

...and the following callbacks...

var goHere = app.callbacks('//here/');
var findHere = app.callbacks('//here');

...it's easy to miss the difference between the function's goHere() and findHere(). The first has the remainder of it's states attached, like so: goHere.and.there(). However, the second is a simple anonymous function, and attempting the same would cause an error.

The difference is subtle and dangerous. A clear spec would help here, so users would understand and expect one or the other type of function, based on sending a string - not the string's value.

@ghost ghost assigned bemson Mar 21, 2013

Owner

bemson commented Apr 4, 2013

Proposals

(A) Append missing ending slash before testing

The first fix is to allow queries missing a forward-slash to be considered absolute queries. Thus, passing the query '//here', should be treated like it were '//here/'.

(B) All dynamic functions persist their original query

Whether a callback will or won't have a tree of linked-functions, the callback itself should reference the initial query. Like cached callbacks, dynamic callbacks will use a custom .toString() method for exposing the original query.

@bemson bemson added a commit that referenced this issue Apr 4, 2013

@bemson bemson Re #28 - Implemented proposals A & B: added ending slash and persisti…
…ng dynamic queries via .toString()
e1e3e50

@bemson bemson closed this in 1c1ce28 Apr 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment