mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-03-16 22:20:23 +00:00
Renamed 'ignoreDuplicates' to 'distinctUntilChanged' to better track with @nicholascloud's contributions on 'distinct'. Bumped version to 0.6.4
This commit is contained in:
parent
bb4217f7fc
commit
4c0aea72b9
22 changed files with 37 additions and 25 deletions
|
|
@ -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();
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
Example 4 - using ignoreDuplicates()
|
||||
Example 4 - using distinctUntilChanged()
|
||||
<ul class="results" id="example4"></ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
2
example/amd/js/libs/postal/postal.min.js
vendored
2
example/amd/js/libs/postal/postal.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
Example 4 - using ignoreDuplicates()
|
||||
Example 4 - using distinctUntilChanged()
|
||||
<ul class="results" id="example4"></ul>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
2
example/standard/js/postal.min.js
vendored
2
example/standard/js/postal.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
2
lib/amd/postal.min.js
vendored
2
lib/amd/postal.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
2
lib/standard/postal.min.js
vendored
2
lib/standard/postal.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -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" );
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ SubscriptionDefinition.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
ignoreDuplicates : function () {
|
||||
distinctUntilChanged : function () {
|
||||
this.withConstraint( new ConsecutiveDistinctPredicate() );
|
||||
return this;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue