Skip to content

Release 3.0.0

Compare
Choose a tag to compare
@KrisSiegel KrisSiegel released this 08 Nov 10:25
· 91 commits to master since this release

The wait is over as version 3.0.0 has arrived! Okay, a little overblown but this version has good stuff in it including optimizations that speed up message handling 2x to 5x depending on environment! Since msngr follows semantic versioning 3.x has breaking changes from 2.x which are outlined in these release notes.

_What's new?_

  • A new msngr.net() interface that provides a single, unified way of hitting HTTP and HTTPS endpoints. This means it works in both the web browser and node.js.
var request = msngr.net("http://www.myexample.org");
request.get({
    path: "/search",
    query: {
        term: "dogs"
    }
}, function(error, result) {
    console.log(result);
});
  • msngr.config() provides an easy way to specify configurations for different parts of msngr. For instance some of the defaults for msngr.net() are simply configuration items that a developer can then override. The same goes for the channel used in the cross-window option. More details in the documentation.
  • msngr.copy() provides a way to deep copy objects. Any type of object it doesn't understand to deep copy is simply returned as is (so it's a quasi deep copy but it's difficult to get better than that while also being useful).
  • msngr.immediate() provides the fastest way possible, in the currently running environment, to execute a method asynchronously. This is a huge performance boost as previously msngr was using setTimeout which was slow in node.js and supremely slow in the browser.
  • isBrowser() provides a check to determine if we're operating in a web browser of not.

_Breaking changes (improvements++)_

  • msngr().on() now sends the callback 3 parameters: payload, message, async. In 2.x msngr sent two (payload, async).
  • msngr.options() is now gone; there are no more global options as this made options being applied too implicit.
  • msngr.executer().execute() method has been removed as it only executed the first item of the supplied methods without being explicit about it. Implicit behavior for the lose.
  • msngr.executer() no longer takes the params of methods, payload, context. Now it accepts either an array of just functions or an array of objects with each object following the format of: { method: function() {}, params: [], context: this }. This allows executer to be more flexible with supplying n number of parameters to each method of which the params can all be different (and executer simply appends its async method as the last parameter of each function call just like before)
  • Creating options now works a lot nicer; instead of directly modifying the internal object you, instead, call a method and supply it with the necessary parameters. No more worrying about messing up the internal structure :). It now looks like this:
msngr.extend(function(external, internal) {
    internal.option("my-option", function(message, payload, options, async) {
        // code here
    });
});
  • msngr.hasWildCard() is now gone. It wasn't being used and was a hold out from 1.0.

_Notables_

  • msngr.now()'s legacy fallback now uses Date.now() instead of Date.getTime().
  • msngr now has benchmarks! To execute run npm run benchmark. This will execute benchmarks in node.js as well as update two html files that allow benchmarks to be run in the browser. Note: the browser benchmarks currently do not automatically run like the unit tests; this will be rectified in a future, minor release.