Class: SC.CascadeDataSource


Extends SC.DataSource.

A cascading data source will actually forward requests onto an array of additional data sources, stopping when one of the data sources returns YES, indicating that it handled the request.

You can use a cascading data source to tie together multiple data sources, treating them as a single namespace.

Configuring a Cascade Data Source

You will usually define your cascading data source in your main method after all the classes you have are loaded.

MyApp.dataSource = SC.CascadeDataSource.create({
  dataSources: "prefs youtube photos".w(),

  prefs:   MyApp.PrefsDataSource.create({ root: "/prefs" }),
  youtube: YouTube.YouTubeDataSource.create({ apiKey: "123456" }),
  photos:  MyApp.PhotosDataSource.create({ root: "photos" })

});

MyApp.store.set('dataSource', MyApp.dataSource);

Note that the order you define your dataSources property will determine the order in which requests will cascade from the store.

Alternatively, you can use a more jQuery-like API for defining your data sources:

MyApp.dataSource = SC.CascadeDataSource.create()
  .from(MyApp.PrefsDataSource.create({ root: "/prefs" }))
  .from(YouTube.YouTubeDataSource.create({ apiKey: "123456" }))
  .from(MyApp.PhotosDataSource.create({ root: "photos" }));

MyApp.store.set('dataSource', MyApp.dataSource);

In this case, the order you call from() will determine the order the request will cascade.

Defined in: cascade.js

Since:
SproutCore 1.0

Field Summary

Instance Methods

Field Detail

dataSources Array

The data sources used by the cascade, in the order that they are to be followed. Usually when you define the cascade, you will define this array.

Instance Method Detail

from(dataSource)

Add a data source to the list of sources to use when cascading. Used to build the data source cascade effect.

Parameters:
dataSource SC.DataSource
a data source instance to add.
Returns:
SC.CascadeDataSource
receiver
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:20 GMT-0600 (CST)