class ChatStore { constructor() { const [state, setStore] = createStore({ apiKey: localStorage.getItem('apiKey') || '', messages: [], currentMessage: '', isStreaming: false, }) this.state = state this.setStore = setStore } setStoreOnce(updater) { this.setStore(produce(updater)) } resetChat() { this.setStoreOnce((s) => { s.messages = [] s.currentMessage = '' s.isStreaming = false }) }