Created
May 8, 2013 08:15
-
-
Save DotNetNerd/5539002 to your computer and use it in GitHub Desktop.
Shows buffering of clicks using Reactive extentions in JavaScript
This file contains hidden or 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
.Add("/scripts/libs/rx.min.js") | |
.Add("/scripts/libs/rx.time.min.js") | |
.Add("/scripts/libs/rx.jquery.min.js") | |
var observer = $(e.target).clickAsObservable().bufferWithTime(200) | |
.subscribe(function (events) { | |
console.log(events.length); | |
var $item = $(e.target).closest('.productItem'); | |
var quantity = parseInt($.trim($item.find('.qty').html())) + events.length + 1; | |
Basket.UpdateQuantity({ LineProductId: $item.attr('data-productId'), Quantity: quantity }, Basket.ShowQuantity); | |
observer.dispose(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment