josephg / ShareJS

Collaborative editing in any app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

server side hook: data not available for model.fetch

ile opened this issue · comments

My server side hook problems continue.

I used to be able to fetch the data with model.fetch, after a create event. Now I seem to get undefined. Not sure what has changed, I think nothing much should have changed.

I get the data if I use a setTimeout of 100 ms, but this may not be ideal or reliable.

A hook callback:

store.hook 'create', 'posts', (docId, op, session, backend) ->
  model = store.createModel()
  if docId and model
    post = model.at "posts.#{docId}"
    model.fetch post, (err) ->
      if !err
        console.log post.get('id')
        console.log post.get()

(Hmm, maybe this should have gone into Racer.)

I have to re-check this...

In any case, this is a racer issue not a sharejs issue