flags

@motioneffector/flags

A TypeScript library for managing application state with powerful condition evaluation and reactive subscriptions.

npm version license TypeScript

Features

Read the full manual →

Quick Start

import { createFlagStore } from '@motioneffector/flags'

const store = createFlagStore({
  initial: { gold: 0, has_key: false, reputation: 50 }
})

// Simple operations
store.set('has_key', true)
store.increment('gold', 25)

// Powerful condition evaluation
if (store.check('gold >= 20 AND !has_key')) {
  store.decrement('gold', 20)
  store.set('has_key', true)
}

// Subscribe to changes
store.subscribe((key, newValue, oldValue) => {
  console.log(`${key}: ${oldValue}${newValue}`)
})

Testing & Validation

License

MIT © motioneffector