Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modella 0.2 support and ajaxParseAllBody and ajaxParseGetBody events #8

Merged
merged 2 commits into from
Oct 28, 2013
Merged

Modella 0.2 support and ajaxParseAllBody and ajaxParseGetBody events #8

merged 2 commits into from
Oct 28, 2013

Conversation

alexmingoia
Copy link
Contributor

Modella 0.2 support and ajaxParseAllBody and ajaxParseGetBody events. Closes modella/ajax/7.

rschmukler added a commit that referenced this pull request Oct 28, 2013
Modella 0.2 support and ajaxParseAllBody and ajaxParseGetBody events
@rschmukler rschmukler merged commit 1c392a5 into modella:master Oct 28, 2013
@rschmukler
Copy link
Member

@alexmingoia you rock dude! I'm going to try and do mongo tonight or tomorrow and ship 0.2.0 later this week.

@rschmukler rschmukler mentioned this pull request Oct 28, 2013
@scttnlsn
Copy link

Nice! What about some event hooks for saving/updating/deleting? It's possible that reusing the ajaxParseGetBody makes sense here.

@rschmukler You mentioned a plugin writing guide here: modella/modella#21 (comment) Is that still in the works?

@alexmingoia
Copy link
Contributor Author

@rschmukler
Copy link
Member

@scttnlsn Yeah, it is. Sorry, I've been working on something else these last few days (which I'll be releasing tonight, if all goes well!) but then I will.

@alexmingoia I think @scttnlsn is saying that having something like having ajaxParseSingleBody instead of ajaxParseGetBody makes sense. And then we use that on response from PUT /users/:id and POST /users/ etc for an opportunity to parse response.

@scttnlsn
Copy link

@rschmukler Awesome! And yes, that's what I was imagining...something to parse the responses from PUT and POSTs to the resource.

@alexmingoia
Copy link
Contributor Author

Agreed we need better event coverage. I propose emitting the event ajax :method_name response for every response. I also propose the space delimited name for easier parsing and conformity with other events.

Example

User.on('ajax get response', function(res) {
    res.body.registeredAt = new Date(res.body.registeredAt);
});

User.on('ajax all response', function(res) {
    var users = res.body.results;
    // Convert JSON string dates into actual dates
    users.forEach(u) {
       u.registeredAt = new Date(u.registeredAt);
    }
    res.body = users;
});


User.on('ajax removeAll response', function(res) {
    // ..
});

User.on('ajax save response', function(res) {
    // ..
});

User.on('ajax update response', function(res) {
    // ..
});

User.on('ajax remove response', function(res) {
    // ..
});

I have time to do this tomorrow afternoon. Thoughts?

@rschmukler
Copy link
Member

@alexmingoia What do you think about dropping the response part? So it becomes ajax update instead of ajax update response... Makes it a bit more concise but maybe a little less descriptive. What do you think?

@alexmingoia
Copy link
Contributor Author

@rschmukler Sounds good. I'm fine with that.

@rschmukler
Copy link
Member

Awesome. If you have time to do it that's awesome. I'm going to try for modella-mongo tomorrow. Today was dedicated to agenda.

@scttnlsn
Copy link

+1 on the shorter event names ajax get, ajax all, ajax save, etc.

@alexmingoia alexmingoia deleted the modella-0.2 branch November 3, 2013 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants