Skip to content

Instantly share code, notes, and snippets.

View bogdanbiv's full-sized avatar
💭
I may be slow to respond.

Bogdan Bivolaru bogdanbiv

💭
I may be slow to respond.
View GitHub Profile

Iterables, AsyncIterables, Observables, Oh My!

I know there is a lot of confusion around Observables, Iterables, AsyncIterables and AsyncObservables. Let's try to break this down and the reasons for each.

Pull versus Push Collections

When it comes to collections, you have two ways of thinking about collections, push versus pull. With pull, the consumer is in control of when you get the items, but with push, you get the values when the producer is ready.

Pull Based Collections

// See http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
(function(global) {
// Maintain a map of already-encountered types for super-fast lookups. This
// serves the dual purpose of being an object from which to use the function
// Object.prototype.toString for retrieving an object's [[Class]].
var types = {};
// Return a useful value based on a passed object's [[Class]] (when possible).
Object.toType = function(obj) {