Class: SC.FixturesDataSource
Extends
SC.DataSource.
Defined in: fixtures.js
- Since:
- SproutCore 1.0
Field Summary
Instance Methods
- fixtureForStoreKey(store, storeKey)
- fixturesFor(recordType)
- fixturesLoadedFor(recordType)
- generateIdFor(recordType, dataHash, store, storeKey)
- hasFixturesFor(storeKeys)
- loadFixturesFor(store, recordType, ret)
- reset()
- setFixtureForStoreKey(store, storeKey, dataHash)
Field Detail
latency NumberIf you set simulateRemoteResponse
to YES
, then the fixtures source will
assume a response latency from your server equal to the msec specified
here. You should tune this to simulate latency based on the expected
performance of your server network. Here are some good guidelines:
- 500: Simulates a basic server written in PHP, Ruby, or Python (not twisted) without a CDN in front for caching.
- 250: (Default) simulates the average latency needed to go back to your origin server from anywhere in the world. assumes your servers itself will respond to requests < 50 msec
- 100: simulates the latency to a "nearby" server (i.e. same part of the world). Suitable for simulating locally hosted servers or servers with multiple data centers around the world.
- 50: simulates the latency to an edge cache node when using a CDN. Life is really good if you can afford this kind of setup.
If YES
then the data source will asynchronously respond to data requests
from the server. If you plan to replace the fixture data source with a
data source that talks to a real remote server (using Ajax for example),
you should leave this property set to YES so that Fixtures source will
more accurately simulate your remote data source.
If you plan to replace this data source with something that works with
local storage, for example, then you should set this property to NO
to
accurately simulate the behavior of your actual data source.
Instance Method Detail
- Parameters:
- store SC.Store
- the store
- storeKey Number
- the storeKey
- Returns:
- Hash
- data hash or null
Get the fixtures for the passed record type and prepare them if needed. Return cached value when complete.
- Parameters:
- recordType SC.Record
- Returns:
- Hash
- data hashes
Generates an id for the passed record type. You can override this if needed. The default generates a storekey and formats it as a string.
Returns YES
or SC.MIXED_STATE
if one or more of the storeKeys
can be
handled by the fixture data source.
Load fixtures for a given fetchKey
into the store
and push it to the ret array.
- Parameters:
- store SC.Store
- the store to load into
- recordType SC.Record
- the record type to load
- ret SC.Array
- is passed, array to add loaded storeKeys to.
- Returns:
- SC.FixturesDataSource
- receiver
- Returns:
- SC.FixturesDataSource
- receiver
- Parameters:
- store SC.Store
- the store
- storeKey Number
- the storeKey
- dataHash Hash
- Returns:
- SC.FixturesDataSource
- receiver