@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
17 lines (16 loc) • 503 B
JavaScript
import { reaction } from './reaction';
export const when = (observableValue, condition, callback) => {
return new Promise((resolve) => {
const disposer = reaction(observableValue, (value) => {
if (condition(value)) {
requestAnimationFrame(() => {
callback();
disposer();
resolve();
});
}
}, {
fireImmediately: true,
});
});
};