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

ES5 Examples #73

Closed
quangv opened this issue Mar 12, 2015 · 3 comments
Closed

ES5 Examples #73

quangv opened this issue Mar 12, 2015 · 3 comments

Comments

@quangv
Copy link

quangv commented Mar 12, 2015

Hey there,

I am interested in using alt for my current project and at the same time have decided to not use ES6, are there any ES5 examples of using Alt?

Thanks.

@goatslacker
Copy link
Owner

There are examples scattered about everywhere but not in a single place in particular.

You can use regular old constructors and prototypes:

function TodoStore() {
  this.todos = {};

  this.bindListeners({
    handleAddTodo: TodoActions.ADD_TODO
  });
}

TodoStore.prototype.handleAddTodo = function (todo) {
  var id = todo.id;
  this.todos[id] = todo;
};

var todoStore = alt.createStore(TodoStore);

@goatslacker
Copy link
Owner

Question: would you prefer to use plain old javascript objects to define stores? You can use the ES3 module pattern with this approach:

(not in master yet)

https://github.com/goatslacker/alt/blob/a-fun-experiment/test/es3-module-pattern.js#L11

@quangv
Copy link
Author

quangv commented Mar 13, 2015

Hey @goatslacker,

Thanks for the reply, I can use it as reference for the other examples in the Readme.

I am using coffee-script + CommonJS/Browserify

@quangv quangv closed this as completed Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants