Renamed 'ignoreDuplicates' to 'distinctUntilChanged' to better track with @nicholascloud's contributions on 'distinct'. Bumped version to 0.6.4

This commit is contained in:
Jim Cowart 2012-05-24 23:13:14 -04:00
parent bb4217f7fc
commit 4c0aea72b9
22 changed files with 37 additions and 25 deletions

View file

@ -100,13 +100,13 @@ starChannel.publish( { topic: "Changed", data: { typ
starSubscription.unsubscribe();
```
### Applying ignoreDuplicates to a subscription
### Applying distinctUntilChanged to a subscription
```javascript
var dupChannel = postal.channel( { topic: "WeepingAngel.*" } ),
dupSubscription = dupChannel.subscribe( function( data ) {
$( '<li>' + data.value + '</li>' ).appendTo( "#example4" );
}).ignoreDuplicates();
}).distinctUntilChanged();
// demonstrating multiple channels per topic being used
// You can do it this way if you like, but the example above has nicer syntax (and *much* less overhead)
postal.channel( { topic: "WeepingAngel.DontBlink" } )
@ -117,6 +117,10 @@ postal.channel( { topic: "WeepingAngel.DontEvenBlink" } )
.publish( { value:"Don't Even Blink" } );
postal.channel( { topic: "WeepingAngel.DontBlink" } )
.publish( { value:"Don't Close Your Eyes" } );
postal.channel( { topic: "WeepingAngel.DontBlink" } )
.publish( { value:"Don't Blink" } );
postal.channel( { topic: "WeepingAngel.DontBlink" } )
.publish( { value:"Don't Blink" } );
dupSubscription.unsubscribe();
```

View file

@ -23,7 +23,7 @@
</div>
<div>
Example 4 - using ignoreDuplicates()
Example 4 - using distinctUntilChanged()
<ul class="results" id="example4"></ul>
</div>

View file

@ -48,12 +48,12 @@ define( ['postal', 'postaldiags'], function ( postal, diags ) {
.publish( { type : "Useless", value : "This won't trigger any subscriptions either" } );
starSubscription.unsubscribe();
// Applying ignoreDuplicates to a subscription
// Applying distinctUntilChanged to a subscription
var dupChannel = postal.channel( "WeepingAngel.*" ),
dupSubscription = dupChannel.subscribe(
function ( data ) {
$( '<li>' + data.value + '</li>' ).appendTo( "#example4" );
} ).ignoreDuplicates();
} ).distinctUntilChanged();
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
@ -62,6 +62,10 @@ define( ['postal', 'postaldiags'], function ( postal, diags ) {
.publish( { value : "Don't Even Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Close Your Eyes" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
dupSubscription.unsubscribe();
// Using disposeAfter(X) to remove subscription automagically after X number of receives

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

File diff suppressed because one or more lines are too long

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

View file

@ -27,7 +27,7 @@
</div>
<div>
Example 4 - using ignoreDuplicates()
Example 4 - using distinctUntilChanged()
<ul class="results" id="example4"></ul>
</div>

View file

@ -47,12 +47,12 @@ $( function () {
.publish( { type : "Useless", value : "This won't trigger any subscriptions either" } );
starSubscription.unsubscribe();
// Applying ignoreDuplicates to a subscription
// Applying distinctUntilChanged to a subscription
var dupChannel = postal.channel( "WeepingAngel.*" ),
dupSubscription = dupChannel.subscribe(
function ( data ) {
$( '<li>' + data.value + '</li>' ).appendTo( "#example4" );
} ).ignoreDuplicates();
} ).distinctUntilChanged();
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
@ -61,6 +61,10 @@ $( function () {
.publish( { value : "Don't Even Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Close Your Eyes" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
postal.channel( "WeepingAngel.DontBlink" )
.publish( { value : "Don't Blink" } );
dupSubscription.unsubscribe();
// Using disposeAfter(X) to remove subscription automagically after X number of receives

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

File diff suppressed because one or more lines are too long

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
{
"name" : "postal",
"description" : "Pub/Sub library providing wildcard subscriptions, complex message handling, etc. Works server and client-side.",
"version" : "0.6.3",
"version" : "0.6.4",
"homepage" : "http://github.com/ifandelse/postal.js",
"repository" : {
"type" : "git",

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

View file

@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

File diff suppressed because one or more lines are too long

View file

@ -165,7 +165,7 @@ QUnit.specify( "postal.js", function () {
subscription = channel.subscribe( function ( data ) {
subInvokedCnt++;
} )
.ignoreDuplicates();
.distinctUntilChanged();
channel.publish( "Testing123" );
channel.publish( "Testing123" );
channel.publish( "Testing123" );

View file

@ -53,8 +53,8 @@ QUnit.specify( "postal.js", function () {
} );
} );
describe( "When setting ignoreDuplicates", function () {
var sDefa = new SubscriptionDefinition( "TestChannel", "TestTopic", NO_OP ).ignoreDuplicates();
describe( "When setting distinctUntilChanged", function () {
var sDefa = new SubscriptionDefinition( "TestChannel", "TestTopic", NO_OP ).distinctUntilChanged();
it( "Should add a DistinctPredicate constraint to the configuration constraints", function () {
assert( sDefa.constraints.length ).equals( 1 );

View file

@ -62,7 +62,7 @@ SubscriptionDefinition.prototype = {
return this;
},
ignoreDuplicates : function () {
distinctUntilChanged : function () {
this.withConstraint( new ConsecutiveDistinctPredicate() );
return this;
},

View file

@ -2,5 +2,5 @@
postal.js
Author: Jim Cowart
License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license)
Version 0.6.3
Version 0.6.4
*/