Last active
December 26, 2015 18:59
-
-
Save aaronj1335/7198616 to your computer and use it in GitHub Desktop.
my proposal for implementing feature flags client-side based on hard-coding a role (we could do a group too, i just used role because it was easy to show the idea).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| 'feature-flags' | |
| ], function(feature) { | |
| // .. instantiate the view and all of that | |
| feature.promise().then(function() { | |
| path.map(url).to(function() { | |
| if (feature.flags.dashboard) | |
| view.show(); | |
| }); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define([ | |
| // this is currently the 'config/feature-flags.json' file, | |
| // and it would be something like `{production: true, staging: false}` | |
| 'json!environment.json' | |
| ], function(environment) { | |
| var productRole = '4e6fa6187a475eefd68fb5f8'; | |
| var object = { | |
| // this is what the widgets will use to access the flags | |
| flags: null, | |
| // deferring this makes it possible to involve an api call in the future | |
| promise: $.Deferred().then(function(flags) { | |
| // also export the flags to the viewmodel so view's templates can bind to them | |
| object.flags = viewmodel.features = flags; | |
| }).resolve({ | |
| dashboard: !environment.production || waterfall.authenticate.role === productRole; | |
| }).promise(); | |
| }; | |
| return object; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment