Code Monkey home page Code Monkey logo

Comments (4)

molily avatar molily commented on July 17, 2024

Chaplin doesn’t provide an own solution how to sync your models and collections, or imposes any restrictions. That means the standard Backbone way using fetch, save, destroy, sync and so on should work fine, and this is still the preferable way. So you should be able to reuse the existing code as it is.

The likes example is just a special case. It could be forced into the standard Backbone fetch/sync model but that would be less elegant since Facebook doesn’t provide a RESTful API. We’re going to add a more common example using Backbone’s standard sync methods soon.

from chaplin.

crussi avatar crussi commented on July 17, 2024

Hi Mathias,
Thanks again for all your responses. I'm truly seeing the elegance of Chaplin and I have been spending many hours studying every part of it. For my notes collection; do you see any problem with fetching the data in my notes_controller? Instead of having the notes initializer call getNotes() and having getNotes() call a service to get data and processNotes() reset the collection; can I have something like below? I'm just not sure where to kick off the collection's fetch. Backbone doesn't have a controller. I want to maintain the same flow as Chaplin. I also want the object (model, collection and view) disposal.

define ['controllers/controller', 'models/notes', 'views/notes_view'], (Controller, Notes, NotesView) ->

'use strict'

class NotesController extends Controller

historyURL: 'notes'

index: (params) ->
  #console.debug 'NotesController#index'
  notes = new Notes()
  notes.fetch()
  @collection = notes
  @view = new NotesView collection: @collection

If this is not how you would go about it; can you please provide some more clarity as to how to kick off a collection getting its own data from a restful api?

Again, thank you for such a beautiful sample application and for the awesome documentation. My hope is that Chaplin will gain traction in the open source community. It is truly an elegant solution.

Best regards,
Chris

p.s. I got this approach working in part, but, I am very interested to hear your opinion on the approach I'm taking.

from chaplin.

molily avatar molily commented on July 17, 2024

Your code should work fine and this is also a straight-forward way.
Don’t know what NotesView is (probably a CollectionView), but as long as the fetching is asynchronous, listening to model changes in the view should work.

from chaplin.

crussi avatar crussi commented on July 17, 2024

Thanks Mathias! I now have the restful service returning data. I am moving on to populate the collection view (NotesView).

Best regards,
Chris

Sent from my iPad

On Mar 9, 2012, at 1:57 AM, Mathias Schä[email protected] wrote:

Your code should work fine and this is also a straight-forward way.
Don’t know what NotesView is (probably a CollectionView), but as long as the fetching is asynchronous, listening to model changes in the view should work.


Reply to this email directly or view it on GitHub:
https://github.com/moviepilot/chaplin/issues/8#issuecomment-4413629

from chaplin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.