Store settings in lowdb
This commit is contained in:
@@ -21,10 +21,11 @@ class IpcMainEventBus implements EventBusInterface {
|
||||
this.ipc = ipc
|
||||
}
|
||||
|
||||
public subscribe<MessageType>(event: Event<MessageType>, callback:(msg: MessageType) => void) {
|
||||
console.log('subscribing', event.topic)
|
||||
this.ipc.on(event.topic, (event: any, arg: any) => {
|
||||
public subscribe<MessageType>(subscribeEvent: Event<MessageType>, callback:(msg: MessageType) => void) {
|
||||
console.log('subscribing', subscribeEvent.topic)
|
||||
this.ipc.on(subscribeEvent.topic, (event: any, arg: any) => {
|
||||
this.client = event.sender
|
||||
console.log(subscribeEvent.topic, arg)
|
||||
callback(arg)
|
||||
})
|
||||
}
|
||||
|
||||
38
events/StorageEvents.ts
Normal file
38
events/StorageEvents.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Event } from './'
|
||||
|
||||
interface StorageEvent {
|
||||
transactionId: string
|
||||
}
|
||||
|
||||
export interface StoreCommand extends StorageEvent {
|
||||
store: string,
|
||||
data: any
|
||||
}
|
||||
|
||||
export interface LoadCommand extends StorageEvent {
|
||||
store: string,
|
||||
}
|
||||
|
||||
export const storageStoreEvent: Event<StoreCommand> = {
|
||||
topic: 'storage/store',
|
||||
}
|
||||
|
||||
export const storageLoadEvent: Event<LoadCommand> = {
|
||||
topic: 'storage/load',
|
||||
}
|
||||
|
||||
export function makeStorageAcknoledgementEvent(transactionId: string): Event<StoreCommand> {
|
||||
return {
|
||||
topic: `storage/ack/${transactionId}`,
|
||||
}
|
||||
}
|
||||
|
||||
export function makeStorageResponseEvent(transactionId: string): Event<StoreCommand> {
|
||||
return {
|
||||
topic: `storage/response/${transactionId}`,
|
||||
}
|
||||
}
|
||||
|
||||
export const storageClearEvent: Event<StorageEvent> = {
|
||||
topic: 'storage/clear',
|
||||
}
|
||||
Reference in New Issue
Block a user