Skip to content
Lance Pollard edited this page Apr 23, 2012 · 1 revision

Pub/sub

Define on the Model

  • no real security w/o passing through the controller layer
class App.User extends Tower.Model
  @sync()
  @publish()
  @subscribe()
  
  @scope "recent", @where(createdAt: ">=": -> _(2).days().ago()).sync()

Define on the Controller

Need to figure out authorization method first, but this will definitely be more secure.

class App.User extends Tower.Model
  @recent: (currentUserId) ->
    # holds permissions
    @where(createdAt: ">=": -> _(2).days().ago()).where(adminId: currentUserId)
  
class App.UsersController extends App.Controller
  @sync "recent", -> @currentUser.get('id')

Tower.js

Everything here will be reflected on http://towerjs.org/guides.

Clone this wiki locally