function ActivityPhraseFeed(el) { if ( ! (this instanceof ActivityPhraseFeed)) { return new ActivityPhraseFeed(el); } Feed.call(this); var self = this; this.el = el || document.createElement('ul'); // initial activities activityMocks.toArray().forEach(function (a) { self.add(a); }); // periodic adds setInterval(function () { self.write(createActivity()); }, 2000); // infinity more! cycle(activityMocks.toArray()).pipe(self.more); // fetch more on click this.el.addEventListener('click', function () { self.fetchMore(10); }); this._renderLoop(); }
it('cycles a piped readable', function (done) { var arrayToCycle = [1,'2',3,{}]; var streamToCycle = new ReadableArray(arrayToCycle); var things = cycle(); streamToCycle.pipe(things); assertCycles(things, arrayToCycle, 20, done); });
} }); // Connect to a Personalized Stream on login function onLogin(user) { // connect to sample stream, which will consistently pump activities sampleStream.connect(user.get('token'), 'sample'); } transform(sampleStream) .forEach(function (data) { console.log('sample stream data', data) }) // Get a 100 activities of all sorts var activities = cycle(activityMocks.toArray()) .pipe(slice(100)); // // Get just the subset of Livefyre ones // var livefyreActivites = activities // .pipe(transform.filter(function (a) { // var actorId = a && a.actor && a.actor.id; // return actorId && /livefyre/.test(actorId); // })); // Livefyre activites go in one feed // livefyreActivities // .pipe(CustomActivityRenderer()) // .forEach(function (el) { // collectionFeed.appendChild(el); // });
it('streams repeatedly the elements of a passed array', function (done) { var arrayToCycle = [1,2,3,4,'7',{},6]; var things = cycle(arrayToCycle); assertCycles(things, arrayToCycle, 20, done); });
it('streams another readable until it ends, then cycles', function (done) { var arrayToCycle = [1,'2',3,{}]; var streamToCycle = new ReadableArray(arrayToCycle); var things = cycle(streamToCycle); assertCycles(things, arrayToCycle, 20, done); });