Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Lets say we have some view called CommentSubmitComponent
// This view will make many things happen. Its job is to send off
// actions from the view and process something.
// Lets make an Action Creator
let CommentSubmitActions = new ZenAction();
// So yeah yeah this is just a plain object at this point. But even so, you have a
// logical place to attach functionality
_.extend(CommentSubmitActions, {
fetchData(collection, query, options) {
// Do something here
submitComment(options, cb) {
return'submitComment', options, cb);
manipulateDOM(template) {
// manipulate some dom
$(template.find('.some-selector')).animate({right: -20px});
changeTemplateState(reactiveVar, update) {
var currentVal = reactiveVar.get();
if (!_.isEmpty(currentVal)) {
// So now I have a bunch of functions that take some params and do some actions.{
'click .button-red': function (event, template) {
// change some state
CommentSubmitActions.submitComment(, commentCallback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment