Allow to watch records using AMB Websockets from a react application.
npm install @lucasschirm/amb-client-reactSimple package that allow you to use the servicenow AMB service on your react application.
To install run the command below on the react app folder
``shell`
npm install @lucasschirm/amb-client-react
To use it on your react component just import and use it like the example below.
`tsx
import useAMB, { encodeQuery } from "@lucasschirm/amb-client-react";
export default function MyComponent() {
const amb = useAMB();
useEffect(() => {
const unsubscribe = amb.subscribe(
"/rw/default/incident/" + encodeQuery("is_active=1"),
(message) => {
console.log(Record changed: , message);
}
);
return () => unsubscribe();
}, []);
}
``