Tracker API reference
Definition
This document provides a detailed walkthrough of the tracker API methods and properties
queueEmpty$
This property type is Subject<boolean> and it will emit to its observers true each time the queue becomes empty
Usage in wrappers
- @pulse/browser
- @pulse/react
import { initializeScoped } from '@pulse/browser';
const pulse = initializeScoped({
app: 'your application name'
});
// Now you can subscribe to queueEmpty$ from pulse object
pulse.queueEmpty$.subscribe();
import { PulseContext } from '@pulse/react';
import { useContext, useEffect } from 'react';
const SomeComponent = () => {
const pulse = useContext(PulseContext);
useEffect(() => {
// Now you can subscribe to queueEmpty$ from pulse object
const subscription = pulse.tracker.queueEmpty$.subscribe();
return () => subscription?.unsubscribe()
}, [])
}
getState
This is a function that returns a Promise<Record<string, unknown>> which represents the Pulse SDK state.
- @pulse/browser
- @pulse/react
import { initializeScoped } from '@pulse/browser';
const pulse = initializeScoped({
app: 'your application name'
});
const pulseState = await pulse.getState();
import { usePulseState } from '@pulse/react';
const SomeComponent = () => {
const { state, loading, hasError } = usePulseState();
return (
<>
{hasError && <div>error</div>}
{!loading && state && <div>{JSON.stringify(state)}</div>}
</>
);
}