These are chat archives for jdubray/sam

3rd
Apr 2017
Marcus Feitoza
@mfeitoza
Apr 03 2017 14:40

Thanks @jdubray ,

model.js

const usersModel = {
  users: {
    page: false,
    per_page: 12,
    total: false,
    data: []
  }
}

app.js

m.route(document.getElementById('example'), '/', {
  '/users/:userId': {
    onmatch (args, path) {
      userModel.userId = args.userId
      let Local = new Same({
        model: userModel,
        actions: {
          getUserById
        },
        acceptor: userAcceptor,
        middlewares: [logger]},
        userState
      )
      return { view () { return Local.view } }
    },
    render (vnode) {
      return vnode
    }
  }

In onmatch(args, path) args are the routing parameters, so I need assign userId to userModel (the extra model data). So I want a more cleaner way to do this.
The onmatch is called once in routing change and `render' every redraw.