Skip to content

Instantly share code, notes, and snippets.

@aerykk
Created February 9, 2020 20:22
Show Gist options
  • Save aerykk/f9353c4bc9c879c6129b1a34d5008a74 to your computer and use it in GitHub Desktop.
Save aerykk/f9353c4bc9c879c6129b1a34d5008a74 to your computer and use it in GitHub Desktop.
const observables: any = {}
const subjects: any = {}
observables.log = Observable.create(subject => {
subjects.log = subject
})
function log(...msgs) {
console.log(...msgs)
if (subjects.log) {
subjects.log.next(msgs)
}
}
export async function init() {
return {
name: 'crypto',
observables,
}
}
export async function init() {
for (const brain of brains) {
const res = await brain.init()
if (res && res.observables && res.observables.log) {
res.observables.log.subscribe(function(msgs) {
db.logs.insert({ brain: res.name, messages: msgs })
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment