Day 18, level up with Backbone.js

Toy problems:

– Solutions for recursiveContains for LinkedList is slightly surprising because contains() should be added to the node, not the list.

Backbone is a monster and we are leveling up in this monster fighting game. Afte spending half an hour with Victor the instructor, I begun to get it. In the mytunes App, click in DOM -> fn() in model, emits events -> events bubble through the collection of models -> App, the main model captures the event and dispatch it to some other model-view pairs. When Googling, someone mentioned about a center event dispatch system for Backbone. Should go check it out when I have time.

A model is the only thing that emits events about itself. Hence, we should only see:


this.trigger()

NEVER this.***.trigger() NOR **.trigger()

Code isolation or modulation should be something we strive for.

Tips:

– Put debugger inside callback()

– window.app = new app() // allow easy access in the console

– Should feel very comfortable calling non-existing functions, to finish the outline of the code

– Grep -r ‘query_string’ .

– Start from the view; only include the top level model / views in index.html

– For Models:

— trigger(‘enqueue’)

— do work to itself if necessary

— do NOT introduce global changes

– For Collections:

— Make sure the item you are trying to listen are actually part of the collection

– For Views

— listen to its models

Advertisements
Standard