forked from mikehostetler/amplify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83e8bf1
commit f1a2814
Showing
12 changed files
with
1,662 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
dist | ||
node_modules | ||
.anvil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"source": "src", | ||
"spec": "test", | ||
"output": { | ||
"full": "lib", | ||
"partial": { | ||
"../vsdoc/amplify-vsdoc.js": "./lib" | ||
} | ||
}, | ||
"anvil.jshint": { | ||
"all": true | ||
}, | ||
"anvil.uglify" : { | ||
"all": true | ||
}, | ||
"dependencies": [ "anvil.jshint", "anvil.uglify" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"./amplify.js": [ "./amplify.core.js", "./amplify.request.js", "./amplify.store.js" ], | ||
"./amplify.core.js": [ "./amplify.core.js" ], | ||
"./amplify.request.js": [ "./amplify.request.js" ], | ||
"./amplify.store.js": [ "./amplify.store.js" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
{{{name}}} - {{{description}}} | ||
version: {{{version}}} | ||
author: {{{author}}} | ||
copyright: 2011 - 2012 | ||
license: Dual licensed (http://appendto.com/open-source-licenses) | ||
MIT (http://www.opensource.org/licenses/mit-license) | ||
GPL (http://www.opensource.org/licenses/gpl-license) | ||
website: http://amplifyjs.com | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
amplify - AmplifyJS is a set of components for data management and application communication. | ||
version: 1.1.0 | ||
author: appendTo (http://appendto.com/) | ||
copyright: 2011 - 2012 | ||
license: Dual licensed (http://appendto.com/open-source-licenses) | ||
MIT (http://www.opensource.org/licenses/mit-license) | ||
GPL (http://www.opensource.org/licenses/gpl-license) | ||
website: http://amplifyjs.com | ||
*/ | ||
(function( global, undefined ) { | ||
|
||
var slice = [].slice, | ||
subscriptions = {}; | ||
|
||
var amplify = global.amplify = { | ||
publish: function( topic ) { | ||
if ( typeof topic !== "string" ) { | ||
throw new Error( "You must provide a valid topic to publish." ); | ||
} | ||
|
||
var args = slice.call( arguments, 1 ), | ||
topicSubscriptions, | ||
subscription, | ||
length, | ||
i = 0, | ||
ret; | ||
|
||
if ( !subscriptions[ topic ] ) { | ||
return true; | ||
} | ||
|
||
topicSubscriptions = subscriptions[ topic ].slice(); | ||
for ( length = topicSubscriptions.length; i < length; i++ ) { | ||
subscription = topicSubscriptions[ i ]; | ||
ret = subscription.callback.apply( subscription.context, args ); | ||
if ( ret === false ) { | ||
break; | ||
} | ||
} | ||
return ret !== false; | ||
}, | ||
|
||
subscribe: function( topic, context, callback, priority ) { | ||
if ( typeof topic !== "string" ) { | ||
throw new Error( "You must provide a valid topic to create a subscription." ); | ||
} | ||
|
||
if ( arguments.length === 3 && typeof callback === "number" ) { | ||
priority = callback; | ||
callback = context; | ||
context = null; | ||
} | ||
if ( arguments.length === 2 ) { | ||
callback = context; | ||
context = null; | ||
} | ||
priority = priority || 10; | ||
|
||
var topicIndex = 0, | ||
topics = topic.split( /\s/ ), | ||
topicLength = topics.length, | ||
added; | ||
for ( ; topicIndex < topicLength; topicIndex++ ) { | ||
topic = topics[ topicIndex ]; | ||
added = false; | ||
if ( !subscriptions[ topic ] ) { | ||
subscriptions[ topic ] = []; | ||
} | ||
|
||
var i = subscriptions[ topic ].length - 1, | ||
subscriptionInfo = { | ||
callback: callback, | ||
context: context, | ||
priority: priority | ||
}; | ||
|
||
for ( ; i >= 0; i-- ) { | ||
if ( subscriptions[ topic ][ i ].priority <= priority ) { | ||
subscriptions[ topic ].splice( i + 1, 0, subscriptionInfo ); | ||
added = true; | ||
break; | ||
} | ||
} | ||
|
||
if ( !added ) { | ||
subscriptions[ topic ].unshift( subscriptionInfo ); | ||
} | ||
} | ||
|
||
return callback; | ||
}, | ||
|
||
unsubscribe: function( topic, callback ) { | ||
if ( typeof topic !== "string" ) { | ||
throw new Error( "You must provide a valid topic to remove a subscription." ); | ||
} | ||
|
||
if ( !subscriptions[ topic ] ) { | ||
return; | ||
} | ||
|
||
var length = subscriptions[ topic ].length, | ||
i = 0; | ||
|
||
for ( ; i < length; i++ ) { | ||
if ( subscriptions[ topic ][ i ].callback === callback ) { | ||
subscriptions[ topic ].splice( i, 1 ); | ||
break; | ||
} | ||
} | ||
} | ||
}; | ||
|
||
}( this ) ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.