Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

more inline examples #27

Merged
merged 2 commits into from Mar 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/authentication/adapters/rest.js
Expand Up @@ -15,6 +15,7 @@
*/
/**
The REST adapter is the default type used when creating a new authentication module. It uses jQuery.ajax to communicate with the server.
This constructor is instantiated when the "Auth.add()" method is called
@constructs AeroGear.Auth.adapters.Rest
@param {String} moduleName - the name used to reference this particular auth module
@param {Object} [settings={}] - the settings to be passed to the adapter
Expand Down
18 changes: 18 additions & 0 deletions src/authentication/aerogear.auth.js
Expand Up @@ -30,6 +30,24 @@

// Create multiple modules using the default adapter
var auth3 = AeroGear.Auth( [ "someAuth", "anotherAuth" ] );

//Create a single module by passing an object using the default adapter
var auth4 = AeroGear.Auth(
{
name: "objectAuth"
}
);

//Create multiple modules by passing an array of objects using the default adapter
var auth5 = AeroGear.Auth([
{
name: "objectAuth"
},
{
name: "objectAuth2",
settings: { ... }
}
]);
*/
AeroGear.Auth = function( config ) {
// Allow instantiation without using new
Expand Down
21 changes: 19 additions & 2 deletions src/data-manager/adapters/memory.js
Expand Up @@ -15,18 +15,22 @@
*/
/**
The Memory adapter is the default type used when creating a new store. Data is simply stored in a data var and is lost on unload (close window, leave page, etc.)
This constructor is instantiated when the "DataManager.add()" method is called
@constructs AeroGear.DataManager.adapters.Memory
@param {String} storeName - the name used to reference this particular store
@param {Object} [settings={}] - the settings to be passed to the adapter
@param {String} [settings.recordId="id"] - the name of the field used to uniquely identify a "record" in the data
@returns {Object} The created store
@exmaple
@example

//Create an empty DataManager
var dm = AeroGear.DataManager();

//Add a custom memory store
dm.add( "newStore", { recordId: "customID" });
dm.add( "newStore", {
recordId: "customID"
});

*/
AeroGear.DataManager.adapters.Memory = function( storeName, settings ) {
// Allow instantiation without using new
Expand Down Expand Up @@ -171,6 +175,19 @@ AeroGear.DataManager.adapters.Memory.prototype.read = function( id ) {
...
});

//Store an array of new Tasks
dm.save([
{
title: "Task2",
date: "2012-07-13"
},
{
title: "Task3",
date: "2012-07-13"
...
}
]);

// Update an existing piece of data
var toUpdate = dm.read()[ 0 ];
toUpdate.data.title = "Updated Task";
Expand Down
21 changes: 19 additions & 2 deletions src/data-manager/adapters/session-local.js
Expand Up @@ -15,20 +15,24 @@
*/
/**
The SessionLocal adapter extends the Memory adapter to store data in either session or local storage which makes it a little more persistent than memory
This constructor is instantiated when the "DataManager.add()" method is called
@constructs AeroGear.DataManager.adapters.SessionLocal
@mixes AeroGear.DataManager.adapters.Memory
@param {String} storeName - the name used to reference this particular store
@param {Object} [settings={}] - the settings to be passed to the adapter
@param {String} [settings.recordId="id"] - the name of the field used to uniquely identify a "record" in the data
@param {String} [settings.storageType="sessionStorage"] - the type of store can either be sessionStorage or localStorage
@returns {Object} The created store
@exmaple
@example

//Create an empty DataManager
var dm = AeroGear.DataManager();

//Add a custom SessionLocal store using local storage as its storage type
dm.add( "newStore", { recordId: "customID", storageType: "localStorage" });
dm.add( "newStore", {
recordId: "customID",
storageType: "localStorage"
});
*/
AeroGear.DataManager.adapters.SessionLocal = function( storeName, settings ) {
// Allow instantiation without using new
Expand Down Expand Up @@ -97,6 +101,19 @@ AeroGear.DataManager.adapters.SessionLocal.prototype = Object.create( new AeroGe
...
});

//Store an array of new Tasks
dm.save([
{
title: "Task2",
date: "2012-07-13"
},
{
title: "Task3",
date: "2012-07-13"
...
}
]);

// Update an existing piece of data
var toUpdate = dm.read()[ 0 ];
toUpdate.data.title = "Updated Task";
Expand Down
19 changes: 17 additions & 2 deletions src/data-manager/aerogear.datamanager.js
Expand Up @@ -34,11 +34,26 @@
var dm3 = AeroGear.DataManager( [ "tasks", "projects" ] );

//Create a custom store
var dm3 = AeroGear.DataManager([{
var dm3 = AeroGear.DataManager({
name: "mySessionStorage",
type: "SessionLocal",
id: "customID"
}])
});

//Create multiple custom stores
var dm4 = AeroGear.DataManager([
{
name: "mySessionStorage",
type: "SessionLocal",
id: "customID"
},
{
name: "mySessionStorage2",
type: "SessionLocal",
id: "otherId",
settings: { ... }
}
]);
*/
AeroGear.DataManager = function( config ) {
// Allow instantiation without using new
Expand Down
1 change: 1 addition & 0 deletions src/pipeline/adapters/rest.js
Expand Up @@ -15,6 +15,7 @@
*/
/**
The REST adapter is the default type used when creating a new pipe. It uses jQuery.ajax to communicate with the server. By default, the RESTful endpoint used by this pipe is the app's current context, followed by the pipe name. For example, if the app is running on http://mysite.com/myApp, then a pipe named `tasks` would use http://mysite.com/myApp/tasks as its REST endpoint.
This constructor is instantiated when the "PipeLine.add()" method is called
@constructs AeroGear.Pipeline.adapters.Rest
@param {String} pipeName - the name used to reference this particular pipe
@param {String} [type="Rest"] - the name used to reference this particular pipe
Expand Down
20 changes: 17 additions & 3 deletions src/pipeline/aerogear.pipeline.js
Expand Up @@ -33,12 +33,26 @@
// Create multiple pipes using the default adapter
var pl3 = AeroGear.Pipeline( [ "tasks", "projects" ] );

//Create a new REST pipe with a custom ID
var pl4 = AeroGear.Pipeline([{
//Create a new REST pipe with a custom ID using an object
var pl4 = AeroGear.Pipeline({
name: "customPipe",
type: "rest",
recordId: "CustomID"
}])
});

//Create multiple REST pipes using objects
var pl5 = AeroGear.Pipeline([
{
name: "customPipe",
type: "rest",
recordId: "CustomID"
},
{
name: "customPipe2",
type: "rest",
recordId: "CustomID"
}
]);
*/
AeroGear.Pipeline = function( config ) {
// Allow instantiation without using new
Expand Down