BASE_FILES = ${SRC_DIR}/core.js\
${SRC_DIR}/callbacks.js\
${SRC_DIR}/deferred.js\
- ${SRC_DIR}/topic.js\
${SRC_DIR}/support.js\
${SRC_DIR}/data.js\
${SRC_DIR}/queue.js\
+++ /dev/null
-(function( jQuery ) {
-
- var topics = {},
- sliceTopic = [].slice;
-
- jQuery.Topic = function( id ) {
- var callbacks,
- method,
- topic = id && topics[ id ];
- if ( !topic ) {
- callbacks = jQuery.Callbacks();
- topic = {
- publish: callbacks.fire,
- subscribe: callbacks.add,
- unsubscribe: callbacks.remove
- };
- if ( id ) {
- topics[ id ] = topic;
- }
- }
- return topic;
- };
-
- jQuery.extend({
- subscribe: function( id ) {
- var topic = jQuery.Topic( id ),
- args = sliceTopic.call( arguments, 1 );
- topic.subscribe.apply( topic, args );
- return {
- topic: topic,
- args: args
- };
- },
- unsubscribe: function( id ) {
- var topic = id && id.topic || jQuery.Topic( id );
- topic.unsubscribe.apply( topic, id && id.args ||
- sliceTopic.call( arguments, 1 ) );
- },
- publish: function( id ) {
- var topic = jQuery.Topic( id );
- topic.publish.apply( topic, sliceTopic.call( arguments, 1 ) );
- }
- });
-
-})( jQuery );
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/sizzle/sizzle.js"></script>
<script src="../../../src/sizzle-jquery.js"></script>
<title>jQuery selector</title>
<script src="../../src/core.js"></script>
+ <script src="../../src/callbacks.js"></script>
<script src="../../src/deferred.js"></script>
<script src="../../src/support.js"></script>
<script src="../../src/data.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/data.js"></script>
<script src="../../../src/queue.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/data.js"></script>
<script src="../../../src/queue.js"></script>
<script src="../../../src/core.js"></script>
<script src="../../../src/callbacks.js"></script>
<script src="../../../src/deferred.js"></script>
- <script src="../../../src/topic.js"></script>
<script src="../../../src/support.js"></script>
<script src="../../../src/data.js"></script>
<script src="../../../src/queue.js"></script>
<script src="../src/core.js"></script>
<script src="../src/callbacks.js"></script>
<script src="../src/deferred.js"></script>
- <script src="../src/topic.js"></script>
<script src="../src/support.js"></script>
<script src="../src/data.js"></script>
<script src="../src/queue.js"></script>
<script src="unit/support.js"></script>
<script src="unit/callbacks.js"></script>
<script src="unit/deferred.js"></script>
- <script src="unit/topic.js"></script>
<script src="unit/data.js"></script>
<script src="unit/queue.js"></script>
<script src="unit/attributes.js"></script>
+++ /dev/null
-module("topic", { teardown: moduleTeardown });
-
-test( "jQuery.Topic - Anonymous Topic", function() {
-
- expect( 4 );
-
- var topic = jQuery.Topic(),
- count = 0;
-
- function firstCallback( value ) {
- strictEqual( count, 1, "Callback called when needed" );
- strictEqual( value, "test", "Published value received" );
- }
-
- count++;
- topic.subscribe( firstCallback );
- topic.publish( "test" );
- topic.unsubscribe( firstCallback );
- count++;
- topic.subscribe(function( value ) {
- strictEqual( count, 2, "Callback called when needed" );
- strictEqual( value, "test", "Published value received" );
- });
- topic.publish( "test" );
-
-});
-
-test( "jQuery.Topic - Named Topic", function() {
-
- expect( 2 );
-
- function callback( value ) {
- ok( true, "Callback called" );
- strictEqual( value, "test", "Proper value received" );
- }
-
- jQuery.Topic( "test" ).subscribe( callback );
- jQuery.Topic( "test" ).publish( "test" );
- jQuery.Topic( "test" ).unsubscribe( callback );
- jQuery.Topic( "test" ).publish( "test" );
-});
-
-test( "jQuery.Topic - Helpers", function() {
-
- expect( 4 );
-
- function callback( value ) {
- ok( true, "Callback called" );
- strictEqual( value, "test", "Proper value received" );
- }
-
- jQuery.subscribe( "test", callback );
- jQuery.publish( "test" , "test" );
- jQuery.unsubscribe( "test", callback );
- jQuery.publish( "test" , "test" );
-
-
- var test = true,
- subscription = jQuery.subscribe( "test", function() {
- ok( test, "first callback called" );
- }, function() {
- ok( test, "second callback called" );
- });
- jQuery.publish( "test" );
- test = false;
- jQuery.unsubscribe( subscription );
- jQuery.publish( "test" );
-});