Skip to content

Latest commit

 

History

History
112 lines (75 loc) · 3.55 KB

README.md

File metadata and controls

112 lines (75 loc) · 3.55 KB

ng-waffle

AngularJS wrapper around Django Waffle

NPM

Build status dependencies devdependencies

Install and use

npm install ng-waffle --save or bower install ng-waffle. Include the ng-waffle.js script in your page and use Waffle module and dependency

angular.module('MyApp', ['Waffle'])
  .run(function (Waffle) {
    if (Waffle.on('enable_hello')) {
        ...        
    }
  });

API

Waffle.set(flag, true|false)

Sets given the flag

Waffle.on(flag)

Shortcut to turn a flag

Waffle.off(flag)

Shortcut to turn off a flag

Waffle.is(flag)

Returns current state of the flag. Alias Waffle.flag_is_active(flag). There is also Waffle.switch_is_active(switchName).

Waffle.reset()

Removes all switches / flags.

Waffle.flags - object with all flags.

Waffle.switches - object with all switches.

Notes

  • If the flag does not exist when checking it using Waffle.is or Waffle.flag_is_active the library treats this as false. You might want to treat this as an asynchronous error. This is useful to detect if the front end waffles got out of sync with back end configuration.

To enable automatic waffle check and treat undefined values like errors, use a provider to configure the Waffle module from the user code.

angular.module('UserApp', ['Waffle'])
    .config(function (WaffleConfigProvider) {
        WaffleConfigProvider.set({
            warnIfMissingFlag: true
        });
    });

License

Author: Kensho © 2015

Support: if you find any problems with this library, open issue on Github

The MIT License (MIT)

Copyright (c) 2015 Kensho

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.