FuroFeatureToggle #
@furo/furo-framework v2.4.11
import '@furo/framework/src/FuroFeatureToggler/FuroFeatureToggle.js';
exports FuroFeatureToggle js
Use the FuroFeatureToggle to control features from a central registry. FuroFeatureToggle only needs a key and a boolean value. These key can be set at any time. A requested key which was not set, is interpreted as false.
Available toggles #
Following toggles are given, use the one which is appropriate to your problem. Sometimes you want to hide some parts if a key is true and sometimes you have to do the opposite.
-
data-furo-toggle-appendAppends the element on true state of the key, removes the element on false state -
data-furo-toggle-removeRemoves the element on true state of the key, appends the element on false state -
data-furo-toggle-hideAdds a hidden attribute to the element on true state of the key, removes the attribute on false state -
data-furo-toggle-showRemoves a hidden attribute from the element on true state of the key, adds the attribute on false state -
data-furo-toggle-disableAdds a disabled attribute to the element on true state of the key, removes the attribute on false state -
data-furo-toggle-enableRemoves a disabled attribute from the element on true state of the key, adds the attribute on false state -
data-furo-toggle-custom-addAdds the custom attribute to the element on true state of the key, removes the attribute on false state -
data-furo-toggle-custom-removeRemoves the custom attribute from the element on true state of the key, adds the attribute on false state
Example usage: #
js #
|
|
html #
|
|
Attributes and Properties #
Methods #
parseDom #
parseDom(root DOM ) ⟹ void
Parses the DOM for feature toggles and applies them.
- root The dom root you want to be managed.
setKeyState #
setKeyState(key String state Boolean ) ⟹ void
Use this method to register a key with an initial state or to update a state.
- key The key of a feature.
- state The state to set.
registerKeyMap #
registerKeyMap(keymap map ) ⟹ void
Use this method to bulk register feature toggles.
- keymap String,Boolean} Object with keys and their initial state
getKeyState #
getKeyState(key String ) ⟹ Boolean
Reads the current state of a key
- key The key of a feature.
registerCallback #
registerCallback(key String cb function(Boolean, KeyState) ) ⟹ void
Register a custom callback on a key.
The callback will be immediately executed when you register it and every time the key state changes.
- key The key of a feature.
- cb The callback method signature is a boolean for the current state and the KeyState object.