SDK Update Sources
| Source | Use for |
|---|---|
journey.view$ | Normal headless rendering and valid actions. |
journey.latestEvent$ | Toasts, announcements, and high-level analytics triggers. |
useExperienceJourney | React UI that wants the current view and lifecycle handling. |
fanfare-journey-change | Web component hosts that need to observe widget state changes. |
React Updates
The React hook updates when the public journey view changes.Core SDK Stores
Headless integrations can subscribe directly to the journey handle.Web Component Events
For framework-agnostic hosts, listen to custom element events.App-Owned Live Data
Use your own polling, SSE, or WebSocket channel for data outside the Fanfare journey contract, such as product copy, merchandising, or checkout preparation.Optimistic UI
Optimistic UI is useful for app-owned controls, but avoid pretending a Fanfare state transition has happened before the SDK view updates. Recommended pattern:- Disable the submitted control while the action promise is pending.
- Keep rendering the last known public view.
- Show a local spinner or progress affordance.
- Replace the UI when the next view arrives.
- Roll back local pending state if the action rejects.
Performance
- Subscribe once per mounted experience surface.
- Unsubscribe on unmount.
- Avoid duplicating SDK providers for the same page area.
- Debounce app-owned visual effects, not SDK state handling.
- Keep analytics high-level and sanitized.
Testing
- Verify view updates change visible UI.
- Verify pending action state does not expose invalid controls.
- Verify unmount cleanup stops app-owned listeners.
- Verify admitted events call your server handoff once.
- Verify telemetry records public outcomes, not raw snapshots or grants.