Skip to content

Latest commit

 

History

History
156 lines (114 loc) · 2.86 KB

README.md

File metadata and controls

156 lines (114 loc) · 2.86 KB

README currently in work

Pre requirements

This app works with play 2.1-SNAPSHOT. At the moment, you must checkout at this commit : a61a48e35a4c6c0e0d28966c84bcbbd0d4d4014a.

PlayStory

PlayStory is an app that receive logs over HTTP, persist them in MongoDB and display them in a Web page in real time.

Back-end

This application use the last features of Play! Framework :

Font-end

PlayStory is a single-web page.
All the javascript code rely on procrastination.js library (https://github.com/jto/procrastination).
Here how I organize the javascript.

Concepts

My application is composed of two pages :

  • The home page.
  • The dashboard page.

The idea is to split each page into several independant views. We usually do a lot to manage a view :

  • We make requests to the server.
  • We listen some events from DOM, server (requests/streams) and javascript router.
  • We update the DOM.

Navigation

My javascript Router have some interesting features:

 Router.when('uri/:param', action1.then(action2))
 Router.when('uri/:param').chain(action1, action2)
 Router.when('uri/:param', action1.and(action2))
 Router.when('uri/:param').par(action1, action2)
Router.when('uri/:param').lazy(function() {
     return action1.then(action2);
});
 Router.fromStart()
       .when('uri/:param')
       .chain(action1, action2)
 Router.from('page')
       .when('uri/:param')
       .chain(action1, action2)
 Router.go('page', true)
 Router.forward()
 Router.back()

Server

Binding to server events.

 server.onReceive('uri/:param')
       .await(actions)
       .subscribe();
 server.onReceiveFromTemplate('model')
       .await(actions)
       .subscribe();

DOM

Binding to DOM events:

 When(event).await(actions).subscribe();

Bucket

'Bucket' is a just one place where you can put some models and collections.

Collection
Bucket.collections('name').get()
Bucket.collections('name').first()
Bucket.collections('name').last()
Bucket.collections('name').size()
Bucket.collections('name').put(model)
Bucket.collections('name').set(collection)
Bucket.collections('name').reset()
Bucket.collections('name').destroy()
Model
Bucket.model('name').get()
Bucket.model('name').set(model)