First off, Flashr is nice. Thanks for creating it!
UI Router is also nice, so it'd be great if Flashr supported it out of the box. Supporting it would be as simple as responding to either $stateChangeSuccess or $routeChangeSuccess events, so for instance:
var displayLaterMessages = function() {
for (var i = 0; i < _toasts.length; i++) {
var object = _toasts[i];
toast(object.type, object.msg);
_toasts = _.difference(object, _toasts);
}
});
$rootScope.$on('$stateChangeSuccess', displayLaterMessages);
$rootScope.$on('$routeChangeSuccess', displayLaterMessages);
Another small change I made locally (that you might consider making?) would be to clear current (now) messages when a state change is initiated, so:
$rootScope.$on('$routeChangeStart', function() {
toastr.clear();
});
$rootScope.$on('$stateChangeStart', function() {
toastr.clear();
});