- 🌲 @btree/core - Framework agnostic behavior trees implementation
- âš› @btree/react - Hooks and docs how to use BT with React
Check docs to learn the API.
npm install @btree/core
import {nodes, tick} from '@btree/core'
const state = {
isLoggedIn: false
}
const tree = nodes.root<typeof state>('App behavior', () =>
nodes.selector([
nodes.sequence([
nodes.conditional((state) => state.isLoggedIn)
nodes.action('Redirect to dashboard', () => {
navigate('/dashboard')
}),
]),
nodes.sequence([
nodes.action('Redirect to login page', () => {
navigate('/login')
}),
]),
])
)
tick(tree, state)
- Kasper Mikiewicz (@Idered)