Observers

React to reward, referral-state, and tier-progress changes in each platform's native idiom

Apps should react the moment referral state changes — confetti when a reward lands, a progress strip that updates live as a referee completes gates — without writing polling code. Every SDK exposes the same three change events in its platform's native idiom.

EventFires when
rewards changedA reward is earned, fulfilled, or claimed — delivers the changed rewards.
referral state changedOne of the user's referrals transitions (signed_up, validated, rejected).
tier progress changedPoints or referrals-to-next-tier change.

Callbacks deliver the changed objects plus a diff hint, on the main thread on mobile. Each underlying change fires exactly once, even across overlapping refreshes. Changes reach the device via smart refresh — the SDK re-fetches on app foreground (tab focus on web), after SDK-initiated actions, and on a modest interval while observers are attached. No polling code, no persistent connection.

The SDK is an event emitter; on returns an unsubscribe function.

invitebase.on(event: InvitebaseEvent, handler: (payload) => void): () => void
invitebase.off(event: InvitebaseEvent, handler): void
EventPayload
rewardsChanged{ rewards: Reward[]; changed: Reward[] }
referralStateChanged{ referral: { id: string; state: string } }
tierProgressChanged{ progress: ReferrerProgress }
const unsubscribe = invitebase.on('rewardsChanged', ({ changed }) => {
  const fresh = changed.find((r) => r.status === 'available');
  if (fresh) {
    confetti();
    toast(`You earned ${fresh.display.title}`);
  }
});

// later
unsubscribe();

What's next

On this page