https://github.com/sproutcore/extensions
High quality extensions to the SproutCore framework
https://github.com/sproutcore/extensions
Last synced: about 1 month ago
JSON representation
High quality extensions to the SproutCore framework
- Host: GitHub
- URL: https://github.com/sproutcore/extensions
- Owner: sproutcore
- Created: 2012-06-14T03:30:27.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2012-06-14T04:37:27.000Z (about 14 years ago)
- Last Synced: 2025-02-24T14:52:48.640Z (over 1 year ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SproutCore Extensions
This repository contains extensions to the SproutCore framework. To use an
extension within your project, clone this repository into the frameworks
directory and include the desired extensions in your Buildfile.
For example,
config :my_app, :required => [:sproutcore, :'extensions/multiplexed_data_source']
## Multiplexed Data Source Extension
* Path: 'extensions/multiplexed_data_source'
* Requires: 'sproutcore/datastore'
* Original Author: Tim Evans
A multiplexed data source will forward data to a number of registered
SC.DataSourceDelegates that accept the SC.Record type provided.
This should be used when you have a single channel that has a multitude of
record types that are non-trivial to transform into data hashes suitable for
the store.
For example,
MyApp.dataSource = SC.MultiplexedDataSource.create({
delegates: 'presence chat muc roster vcard'.w(),
presence: MyApp.PresenceDataSourceDelegate,
chat: MyApp.MessageDataSourceDelegate.extend({ type: 'chat' }),
muc: MyApp.MultiUserChatSourceDelegate,
roster: MyApp.RosterItemDataSourceDelegate,
vcard: MyApp.VCardTempDataSourceDelegate
});
MyApp.store.set('dataSource', MyApp.dataSource);
The order of the delegates is irrelevant. Queries and CRUD actions will
be forwarded to the apropriated delegate(s).
Alternatively, you can use a more jQuery-like API for defining your data
sources:
MyApp.dataSource = SC.MultiplexedDataSource.create()
.from(MyApp.PresenceDataSourceDelegate)
.from(MyApp.MessageDataSourceDelegate.extend({ type: 'chat' }))
.from(MyApp.MultiUserChatSourceDelegate)
.from(MyApp.RosterItemDataSourceDelegate)
.from(MyApp.VCardTempDataSourceDelegate)
MyApp.store.set('dataSource', MyApp.dataSource);
A similar API can be used before creation time that allows SC.DataSourceDelegates
to be wired to their parent SC.DataSource via the `plugin` method.
The child delegates have direct access to the parent SC.MultiplexedDataSource,
which acts like a hub where all common functions and properties should be
placed.