Hey, I've added the new version instead of edit the old as its a complete rewrite.
In brief, the main changes are:
A single window resize event listener that operates pub/sub style. Broadcasts from rootscope to wherever you bind a scope.on() listener. Configurable debounce && option to disable at config.
Truthiness of matches on resize are now only returned if they have changed.
is no longer takes an array, because I wanted an immutable variable for the directive. Was there a use case for this?
on has been renamed to bind for clarity, and now returns an object with two properties, active bool which reflects the truthiness of the match, and fn unbind which deregisters the listener.
when has been renamed to once for clarity and now fires a callback a single time on a successful match. Because data calls should be cached so no need to refire them every time you match.
Predefined rules, custom rules or extend existing rules all now done at config.
New directive.. works like ngIf on match
Changed the module name, because there are so many similar ones on github already. Changed the service name to match, for consistency.
Update: I changed bind to make it easier to assign & deregister. I was thinking of adding a if else style method too when I get time, that takes two callbacks and alternately fires them on match/unmatch. Or a when and not method that seperately fire callbacks. Or all 3! :P
Let me know if you want me to submit a PR with fewer changes first.
Hey, I've added the new version instead of edit the old as its a complete rewrite.
In brief, the main changes are:
is
no longer takes an array, because I wanted an immutable variable for the directive. Was there a use case for this?on
has been renamed tobind
for clarity, and now returns an object with two properties,active
bool which reflects the truthiness of the match, and fnunbind
which deregisters the listener.when
has been renamed toonce
for clarity and now fires a callback a single time on a successful match. Because data calls should be cached so no need to refire them every time you match.Update: I changed bind to make it easier to assign & deregister. I was thinking of adding a
if else
style method too when I get time, that takes two callbacks and alternately fires them on match/unmatch. Or awhen
andnot
method that seperately fire callbacks. Or all 3! :PLet me know if you want me to submit a PR with fewer changes first.