-
Notifications
You must be signed in to change notification settings - Fork 25
[feature] Add beforeAction and afterAction event callback #13
Comments
Hi @guiltry – indeed this seems pretty similar to what we're discussing in #9. I like that it enables to use the blueprints in whichever style you want and makes the model lifecycle more powerful. I always wondered why the original Sails beforeCreate lifecycle method was so limited and didn't give access to the request from the client. |
OMG, sorry I didn't read PR and that just 22 hours ago. Haha. Doesn't it good? I guess it's the sails team purpose. |
@mphasize I've been trying to find a good way to catch 500 errors thrown by MongoDB when adding duplicate values to a unique key. I tried using a I think this would also help solve the issue you raise at: https://github.com/balderdashy/waterline/issues/295#issuecomment-45596117 |
I put together a Policy that removes the need for the uncommented lines in the I'm planning to put together another Policy that enables the before* hooks with access to req on the model definition. This way we can keep this stuff out of the blueprints and have it easily extendable. Thoughts? |
@mphasize That looks pretty good from what I can tell, but I think would also interest @mgenev who is mostly responsible for https://github.com/Globegitter/sane-auth. To make sure they work nicely together :) |
Also @mphasize I just had a chat with @huafu the creator of https://github.com/huafu/ember-data-sails. It would be really nice to have these two plugins work nicely together to just get Websockets 'for free'. He said he does want to switch to conform to the RESTAdapter, his biggest question do you know if these blueprints also just work with websockets? But maybe you can also have a little chat here yourself :) |
@huafu @Globegitter I kept the websocket specific stuff from the original blueprints and didn't modify it. So there's a chance that websockets "just work", however I've never tried it because I'm not yet using sockets. |
@guiltry @Globegitter |
@mphasize Beautiful! |
@mphasize @Globegitter the latests I do believe that you can either use one or the other adapter (original You could have |
@huafu Yep, thinking along the same lines here. Somebody just needs to go check if it works. :-D |
We do not have a solution for an |
@mphasize so I've fixed some issue appearing with the prototype extension from Ember conflicting with some stuff in sails io js, and published So either there is a simple way to disable your blueprints for websocket and enable them only for http, or I'll have to add an option in my addon to be set when used with your blueprints :-/ (and of course change the code to handle that). Any clue if it is possible to simply use your blueprints only for http? |
@mphasize ok, it DOES work by setting the |
… sails-generate-ember-blueprints See mphasize/sails-generate-ember-blueprints#13
@huafu So we really have an out-of-the-box solution here? That's great news and thanks a lot for figuring out how to do the right setup! |
yup! still want to work on more unit tests, but yup, all working ;-) |
@huafu do you have the working example somewhere lying around that can go up on github? :) |
Hi,
What if we add an event hook base on sails service.
For example, we can change this part,
to this,
and inside beforeCreate service,
List action:
etc.
Then, people will move their logic outside and we can easily support for backward compatibility.
If you want, I'll create a PR about this.
Btw. thanks for this awesome repo. 😄
The text was updated successfully, but these errors were encountered: