4.7.0 • Published 6 months ago

cozy-flags v4.7.0

Weekly downloads
298
License
MIT
Repository
github
Last release
6 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.

4.7.0

6 months ago

4.4.0

10 months ago

4.3.1

10 months ago

4.6.1

10 months ago

4.6.0

10 months ago

4.5.0

10 months ago

4.3.0

10 months ago

4.2.0

10 months ago

4.0.3

10 months ago

4.1.0

10 months ago

4.0.1

11 months ago

4.0.2

11 months ago

4.0.0

1 year ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.12.0

2 years ago

2.11.0

3 years ago

2.10.2

3 years ago

2.10.1

3 years ago

2.10.0

3 years ago

2.9.0

3 years ago

2.8.7

3 years ago

2.8.6

3 years ago

2.8.3

4 years ago

2.8.2

4 years ago

2.8.5

4 years ago

2.8.4

4 years ago

2.8.1

4 years ago

2.8.0

4 years ago

2.7.2

4 years ago

2.7.1

4 years ago

2.7.0

4 years ago

2.6.0

4 years ago

2.5.4

4 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.5

5 years ago

2.3.4

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.0

5 years ago

2.3.1

5 years ago

2.2.5

5 years ago

2.2.4

6 years ago

2.2.1

6 years ago

2.2.3

6 years ago

2.2.2

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.11.0

6 years ago

1.10.0

6 years ago

1.9.3

6 years ago

1.9.2

6 years ago

1.9.1

6 years ago

1.9.0

6 years ago

1.7.0

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.9

6 years ago

1.5.8

6 years ago

1.5.7

6 years ago

1.5.6

6 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.12

7 years ago

1.2.11

7 years ago

1.2.10

7 years ago

1.2.9

7 years ago

1.2.8

7 years ago

1.2.7

7 years ago

1.2.6

7 years ago

1.2.5

7 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago