Config
The ScaleBun.config namespace — 2 members.
Phase 4: runtime config delivered via GET /v1/config. All resolution is local and non-throwing; values default sensibly until init() runs / config is fetched.
import ScaleBun from '@scalebun/react-native';
ScaleBun.config.<method>(…);Members#
| Member | Signature |
|---|---|
get | get(key: string, fallback: T): T |
refresh | refresh() |
Reference#
get#
ScaleBun.config.get(key: string, fallback: T): Trefresh#
ScaleBun.config.refresh()Notes#
config reads remote configuration — values you set in the dashboard and your app reads at runtime,
without shipping a release.
get(key, fallback) is deliberately shaped so a fallback is not optional. That is the whole contract
of this namespace: a config read must always produce a usable value, because the alternatives —
throwing, or returning undefined into your render path — turn a configuration service outage into
an app outage.
The fallback is your real default#
Write the fallback as the value you would have hardcoded. It is used whenever the remote value is unavailable: before the first fetch resolves, when the device is offline, when the key does not exist, and when the stored value fails to coerce to the expected type.
That last case is easy to miss. A key you changed from a number to a string in the dashboard will fall back for every client still expecting a number.
Ordering#
Do not read config before init()
Unlike events, config reads are not buffered — there is nothing to buffer, since a read must return now. Before
init()you get the fallback.refresh() only when you need it
The SDK fetches on its own schedule. Call
refresh()when your app reaches a natural boundary where new values should take effect — a foreground, or entering a screen whose behaviour is configured.Re-read after a refresh
refresh()updates the stored values; it does not re-render your app. Read the key again, or drive your UI from state you update after refreshing.
Limits and edge cases#
Config is not a feature flag. For on/off behaviour use
flags, which is designed for it and is reported on separately.Values are not secrets. They are delivered to the client and readable by anyone with the app.
No change notification. There is no subscription callback — you read, or you refresh and read.