3.2.2 • Published 4 months ago

cozy-flags v3.2.2

Weekly downloads
298
License
MIT
Repository
github
Last release
4 months ago

Flags

Use and manage cozy feature flags. Flags can be toggled for a cozy instance, a context or globally. See the stack documentation on flags for more information.

  • ✅ jQuery like API for getter/setter
  • ✅ Devtool component to set/unset flags

Installation

npm install --save cozy-flags
# or yarn add cozy-flags

A CozyClient plugin is exported that

  • initializes flags on client's login
  • resets them on client's logout
import flag from 'cozy-flags'
client.registerPlugin(flag.plugin)

ℹ️ It will fetch server flags for consumption by the app

  • either from DOM data (if data-cozy={{ .CozyData }} or data-flags={{ .Flags }}, on web
  • or by fetching data from the server (on mobile)

Usage

⚠️ Make sure you have registered the flag plugin before using the flags.

import flag from 'cozy-flags'

if (flag('my-feature')) {
  enableMyFeature()
}

The FlagSwitcher shows all flags in use and displays all flags in use.

import flag from 'cozy-flags'
import FlagSwitcher from 'cozy-flags/dist/FlagSwitcher'

if (process.env.NODE_ENV !== 'production'
    && flag('switcher') === null) {
    flag('switcher', true) // set default flag in dev mode
}

const App = () => {
  return (
    <div>
      { flag('switcher') && <FlagSwitcher /> }
      <MyApp />
    </div>
  )
}

Demo

The FlagSwitcher component helps toggling the flags.

Flags enabled at build time

It is possible to handle flags enabled at build time. Your app should just provide a global __ENABLED_FLAGS__ array with flag names that should be enabled. If such a global exists, cozy-flags will iterate on the array and enable all the flags it contains when it is imported.

3.2.2

4 months ago

3.2.1

4 months ago

3.2.0

4 months ago

3.1.0

6 months ago

3.0.1

1 year ago

3.0.0

1 year ago

2.12.0

1 year ago

2.11.0

1 year ago

2.10.2

2 years ago

2.10.1

2 years ago

2.10.0

2 years ago

2.9.0

2 years ago

2.8.7

2 years ago

2.8.6

2 years ago

2.8.3

2 years ago

2.8.2

2 years ago

2.8.5

2 years ago

2.8.4

2 years ago

2.8.1

2 years ago

2.8.0

3 years ago

2.7.2

3 years ago

2.7.1

3 years ago

2.7.0

3 years ago

2.6.0

3 years ago

2.5.4

3 years ago

2.5.3

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.1

4 years ago

2.4.0

4 years ago

2.3.5

4 years ago

2.3.4

4 years ago

2.3.3

4 years ago

2.3.2

4 years ago

2.3.0

4 years ago

2.3.1

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.1

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.11.0

4 years ago

1.10.0

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.7.0

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.9

5 years ago

1.5.8

5 years ago

1.5.7

5 years ago

1.5.6

5 years ago

1.5.5

5 years ago

1.5.4

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.12

5 years ago

1.2.11

6 years ago

1.2.10

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago