// get data for stream "bdainton/kindle"
var stream = new massrel.Stream('bdainton', 'kindle');
stream.poller({
limit: 10, // number of tweets per poll
frequency: 30 // how often to get new tweets
}).batch(function(tweets) {
// resort so tweets on top are the newest
reorder = [];
while(tweets.length > 0) {
reorder.push(tweets.pop());
}
// print array of new tweets
console.log(reorder);
}).start();
var stream = new massrel.Stream('bdainton', 'kindle');
//gets a NEW poller for the stream
var poller = stream.poller();
For each poller instance usually a callback is either added to .each or .batch but not both
Callback invoked for each tweet as they come in from oldest tweet to newest
poller.each(function(tweet) {
// invoke for every tweet that is return from the api
// from oldest to newest
console.log(tweet);
// "this" is the poller instance
})
Callback invoked for each poll that has more than zero tweets
poller.batch(function(tweets) {
// all tweets from each poll that have > 0 tweets
console.log(tweets);
// "this" is the poller instance
})
// start grabbing tweets
poller.start();
setTimeout(function() {
// in 1 minute, stop getting tweets
poller.stop();
}, 60000);
// the best part is that it is chainable
stream.poller({ frequency: 30 }).each(function(tweet) {
var container = document.getElementById('tweet-quick');
var ptag = document.createElement('p');
ptag.innerHTML = tweet.text;
container.insertBefore(ptag, container.firstChild);
}).start();
Basically if you want to display tweets on a regular interval
// here is an example of delayed queue
var poller = stream.poller();
var queue = new massrel.PollerQueue(poller);
poller.start();
queue.next(function(tweet, step) {
var container = document.getElementById('tweet-delay');
var ptag = document.createElement('p');
ptag.innerHTML = tweet.text;
container.insertBefore(ptag, container.firstChild);
setTimeout(step, 1000);
});
Shorthand
var poller = stream.poller().queue(function(tweet, step) {
var container = document.getElementById('tweet-delay');
var ptag = document.createElement('p');
ptag.innerHTML = tweet.text;
container.insertBefore(ptag, container.firstChild);
setTimeout(step, 1000);
}).start();
- Install node v0.10
- Install npm packages
npm install
- Install grunt
npm install -g grunt-cli
grunt build
This will build massrel.js
and massrel.min.js
into the build
directory and run test suite.
- Choose version using semantic versioning
- Update change log
- Set version in package.json
- Set version in component.json
- Run
grunt release
- If tests pass, commit changes
- Tag version in git
git tag 0.0.0 && git push origin 0.0.0
(where 0.0.0 is version)
- Add network parameter to Search poller
- Add tweet_mode parameter to meta poller
- Add tweet_mode parameter to Top Things
- Add tweet_mode parameter to stream
- Add products parameter to stream
- Add nonsquare_instagram parameter to stream
- Add API Token to search requests if supplied
- Add target, precision to compare poller
- Add param tests to compare poller
- Add poller for Facebook Media Polls
- Add strip_links parameter to stream poller
- Add all_topics parameter to meta poller
- Add activity parameter to meta poller
- Implemented another workaround for twitter iOS webview issue identified in v1.7.2
- Implemented workaround for https://twittercommunity.com/t/intent-clicked-from-within-uiwebview-in-twitter-ios-app-ignores-hashtags-parameter/24096
- Fixed invalid require path in
search.js
- Added basic search object
- Fix version tagging problems.
- Convert the Top Things Poller to work exclusively with relative time strings
- Add additional param for
TopThingsPoller
- Add additional param to
StreamKeywordInsights
class
- Added POST CORS support
- Removed request counter and console warnings
- Add
lang
param toStream
object - Remove queue history from
PollerQueue
(it was never used)
- api.massrelevance.com as default API host
- Add additional params to
Accounts
class - Fix XHR2 feature test that failed in certain IE8 environments
- support stream activity API through
StreamActivity
class
- Support src/massrel being the entry point for a require.js package
- If included as a require.js package, does not create window.massrel
timeframe
params
- Stream Keyword Insights API support through
Stream#keywordInsights
(9269d03ef1)
- 'klout' is a new stream param (55fc7f3de9)
- Add context.sourceName property
- Add support for page_links parameter
- fix google plus source detection in Context
- Add TopThingsPoller
- Add missing meta poller params
- Add GetGlue support to Context
- Add helpers.always
- Add Context.getPhotoUrl
- Add RSS to Context
- Fix bug in 0.13.10
- Fix original_referer in tweet intent
- Improve Facebook network detection
- Fix the way intents#user parses
screen_name_or_id
when it contains a number
- Fix broken Poller#more and add tests (c4550cbf6a)
- Minor changes to the request counter
- Add missing param to Poller#queue (955cebec5b)
- Switch to anonymous define for external AMD loaders (55d7840e96)
- Warn if too many requests made in a minute (1050d4f16b)
- Allow override of default stream poller options for initial poll (13eca5e698)
- Refactored CORS req so IE10 will use XHR2 object
- Bug fix for backoff shortening delay if greater than backoff max
- Implement
GenericPoller
that all other pollers inherit from. Handles polling delay backoff when errors happen (b99c01e4fa) - Add hail mary mode to
Poller
which will make stream requests withoutsince_id
and do request diffs client side (b99c01e4fa) - Override default host when massrel[host] URL param is used (087fe37eab)
- Refactor
helpers.parse_params
(bcbf443e9a)
- Moved back to single built file, rather than internal/external builds.
- Almond.js updated to latest stable version.
- Cast all
fix_date
inputs to strings to resolve IE issues (ec390e725d)
- CORS support. Cross domain requests to API when browser supports it instead of JSONP. (259ed3563a)
- Filter stream to a single network (3f945b85c5)
- Allow port and host overrides on the massrel module (0be2bbedbf)
- Correct typo with
Compare
support (44a744b073) networks
is a new param onStream#meta
(623b28993e, db1155493e)- Improve date support for IE 7 - 8 in
fix_date
(1b6fc24b5d)
- Automatically add
original_referer
param when using intents URL helper (5fd729243b) Context
class supports Google+ and Instagram types (6158535fb3)num_trends
is a new param onStream#meta
(cefde81cae)Compare
API support (usenew massrel.Compare
)top_count
is a new param onStream#meta
(4aabe2e7c7)
top_period_relative
is a new param onStream#meta
(b0e3013f24)- bind current poller instance to
this
inPoller#more
callback (45e8c496a3) - fixed bug so that the massrel.js lib doesn't replace any existing global massrel global object (71ac8a739e)
- fixed bug that prevented newer statuses from being pulled in correctly if
Poller#more
was called beforePoller#start
(19c96fc767) stay_realtime
is a new param forPoller
(default: true) (replaces oldcatch_up
param) (cb9c796692...f860ea3ba0, and bug fix c85cd339d3)
num_hours
is a new param onStream#meta
keywords
now works when polling streamer
- catch race condition that prevents
MetaPoller
from being stopped when called to stop (fixes #1) num_days
is a new param onStream#meta
num_minutes
is a new param onStream#meta
- intent url generator (e.g.
massrel.intents.tweet({ text: 'Awesome!!', hashtags: ['awesome', 'nice'] });
)
- enable intents by default in
Context
top_periods
is a new param onStream#meta
finish
is a new param onStream#meta
- added a way for you to update
MetaPoller
options on the fly
- add
keywords
param for streams - meta poller for Account (use
Account#metaPoller
) - global minimum poll value. for use in a possible QoS implementation
- fix mispelled method names in
Account
andStream
which caused#meta
to break when called (builMetaParams
changed tobuildMetaParams
)
- added
Poller#more
method to pull older statuses from a timeline. It keeps track of the last item in the list for subsequent requests - created query param builder methods for stream and account requests (use
Stream#buildParams
,Stream.buildMetaParams
, orAccount#buildMetaParams
)
- added conveniece wrapper for polling stream meta info (use
Stream#metaPoller
) - define API as AMD if public AMD
define
method exists
- first versioned package
- overhall system to use jburke/r.js & almond for build system