Grants the ability for views (and related data) to be persisted beyond one controller action.
module.exports = class ServiceController extends Controller
index: ->
@collection = new Services
@view = new ServiceCollectionView {@collection, region: 'main'}
@collection.fetch().then @view.render
module.exports = class Controller extends Chaplin.Controller
# Compositions persist stuff between controllers.
# You may also persist models etc.
beforeAction: ->
@reuse 'site', SiteView
@reuse 'header', HeaderView, {region: 'header'}
@reuse 'footer', FooterView, {region: 'footer'}
@reuse 'itemRecommendations',
compose: ->
@item = new ItemRecommendations [],
context: {type: 'Product', scenario: 'Variant Detail'}
data = {ids: [params.variantId]}
if isBrowsing
getRecommendationsCallback @item, data
else
unless member.isSynced()
@listenToOnce member, 'sync', =>
getRecommendationsCallback @item, _.extend data,
member_id: member.id
, options.query
else
getRecommendationsCallback @item, _.extend data,
member_id: member.id
, options.query