Uh oh!
There was an error while loading. Please reload this page.
Conversation
There was a problem hiding this comment.
This provides a more helpful error message when the test fails:
expect(this).to.have.property(foo, 'bar');
bajtos
commented
Oct 15, 2014
Can we use a different name than There is also inconsistency in If there is What is the relation between |
ritch
commented
Oct 15, 2014
This name was original decided on in the overall component design...? I'd like to move forward since we already agreed on it there. I'm not really a fan of
I haven't had the need for it in my examples. I think its nice to allow anonymous handlers without having to create a phase. This is eventually what will allow people to easily hook into phases. Eg. you need something that is created in the app.phase('foo').after(useSomethingDefinedInFoo); |
ritch
commented
Oct 15, 2014
These are shorthand for |
bajtos
commented
Oct 16, 2014
IIRC, the decision was to come up with a better name when we get to review the code, so that the initial discussion can focus on the big picture.
I really don't want to waste my time on support explaining LoopBack users what is the intent of the register function. This is the new public API we will have to support for long time, it will be difficult to change it later. Therefore I want us to find a better name now.
Fair enough, we can always add
We are creating several ways how to order the execution of phase functions:
My concerns:
BTW is
Brainstorming few alternatives: // before, on, after - `on` can be confused with EventEmitter :(app.phase('preprocess').on(function(){/*...*/});// beforeRun, onRun, afterRunapp.phase('preprocess').onRun(function(){/*...*/});// registerBeforeHandler, registerHandler, registerAfterHandlerapp.phase('preprocess').registerHandler(function(){/* ... */});// addBefore, addHandler, addAfterapp.phase('preprocess').addHandler(function(){/*...*/});I agree this discussion should not change into bikeshedding. If we can't come up with anything better, I am fine with dropping |
bajtos
commented
Oct 16, 2014
We may need to add an error handler (error logger?) function in the future. E.g. |
b587863 to
cc3a923Compareritch
commented
Oct 16, 2014
What is wrong with the I think we should add this in another PR. |
ritch
commented
Oct 16, 2014
The only way you can add handlers is with the following methods:
|
ritch
commented
Oct 16, 2014
What about: phase.addHandler(function(cb){// ...}); |
ritch
commented
Oct 16, 2014
This ended up being trivial to add. |
ritch
commented
Oct 16, 2014
@kraman had a good idea for naming: app.phase('preproccess').addTask(function(cb){// ...});app.phase('preprocess').addPreLaunchTask(function(){// ...});app.phase('preprocess').addPostLaunchTask(function(){// ...}); |
ritch
commented
Oct 16, 2014
@bajtos / other reviewers - please take a look at the docs as well: git checkout 1.0
sdocs -p |
raymondfeng
commented
Oct 16, 2014
A few comments:
app.phase('preproccess').use(function(cb){// ...});app.phase('preprocess').pre(function(){// ...});app.phase('preprocess').post(function(){// ...}); |
ritch
commented
Oct 16, 2014
I thought about this. I prefer the redundancy and the clarity in the documentation. Specifying that |
ritch
commented
Oct 16, 2014
This doesn't really make sense in the context of a |
altsang
commented
Oct 16, 2014
+1 addHandler(), is there a removeHandler() as well? strange to me as well to have after() without before() and if next is "special" - +1 for making it private I do agree with @bajtos to a certain degree that if this is a public API that we should try to get to a good level of consistency upfront but not end up in the bikeshed |
ritch
commented
Oct 16, 2014
I've learned my lesson in strong-remoting accepting booleans like this. I prefer the clarity in the method name. |
ritch
commented
Oct 16, 2014
ritch
commented
Oct 16, 2014
bajtos
commented
Oct 17, 2014
-100 for boolean parameters, it's a strong code smell. +100 for using different a method name documenting the intent of the method As for naming, any of these work fine for me:
Few more alternatives:
|
bajtos
commented
Oct 17, 2014
Consider this example: varphaseSet=newPhaseSet();phaseSet.addInOrder(['one','two','three']);phaseSet.phase('one').next=newPhase();My expectations:
Which opens another point - your test suite is missing tests verifying the order in which the phases and their handlers are executed. |
ritch
commented
Oct 17, 2014
Take a look at this... I can add a before handler to ensure that is always executed first. |
ritch
commented
Oct 17, 2014
This is the behavior. If you have suggestions on how to clarify on this docs LMK. |
ritch
commented
Oct 17, 2014
Just had a discussion with @raymondfeng and @bajtos. We decided to go with:
|
There was a problem hiding this comment.
Please add some tests verifying phase ordering. E.g. that foo will be executed before bar.
There was a problem hiding this comment.
OK, I see the ordering is covered by PhaseList phases.toArray() should return the list of phases as an array.
There was a problem hiding this comment.
Each PhaseList should have a name.
bajtos
commented
Oct 22, 2014
A subjective opinion: I find it better to add Whatever option you choose, please use it consistently. ATM there is |
ritch
commented
Oct 22, 2014
Fixed |
bajtos
commented
Oct 31, 2014
@ritch |
/to @bajtos
/cc @raymondfeng
Please review the following.
https://github.com/strongloop/loopback-phase/blob/1.0/example/middleware.js => example for our middleware use case.
https://github.com/strongloop/loopback-phase/blob/1.0/test/phase.test.js => the phase API / test
https://github.com/strongloop/loopback-phase/blob/1.0/test/phase.test.js => the phaseSet API / test
Also take a look at the example in the README.md. Everything else is copied from loopback-boot.