Search code examples
web-applicationscoffeescriptchaplinjs

chaplin.js SyncMachine calls


I am currently creating a CollectionView with a loadingIndicator in chaplin.js. In the initialize function of my corresponding collection I have to call initSyncMachine() like this

initialize: ->
    super
    @initSyncMachine()

I realize that this is necessary in order for the collection to trigger the sync events my CollectionView listens to. But do I really have to call beginSync() and all the other functions as well? Isn't that done by the sync method in backbone.js?

My initialize function currently looks like this:

initialize: ->
  super
  @initSyncMachine()
    @fetch
      success: =>
        @finishSync()
      error: =>
        @abortSync()

The chaplin.js facebook example does this, but has legitimate reason to do so. It overrides the fetch() method and calls beginSync() while calling finishSync() in another function.


Solution

  • Turns out this is something that has not yet been implemented. So yes: I will have to call the functions manually.
    It seems like this is something that is going to be implemented though: https://github.com/chaplinjs/chaplin/issues/91