Last active
September 2, 2019 19:50
-
-
Save michaelsbradleyjr/271c3dabdabf68412e254d52b3934e62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in the top parts of the module with other imports/requires | |
const {fromEvent: rxFromEvent, interval: rxInterval, partition: rxPartition} = require('rxjs'); | |
const {debounce: rxDebounce} = require('rxjs/operators'); | |
const {AsyncIterableX: {from: ixFrom}, batch: ixBatch} = require('ix/asynciterable'); | |
// ----------------------------------------------------------------------------- | |
const fileChanges$ = rxFromEvent(engine.events, 'file-event'); | |
const [assets$, others$] = rxPartition( | |
fileChanges$, | |
({fileType}) => fileType === 'asset' | |
); | |
const [contractsAndConfigs$] = rxPartition( | |
others$, | |
({fileType}) => ['config', 'contract'].includes(fileType) | |
); | |
ixBatch(ixFrom(assets$.pipe(rxDebounce(() => rxInterval(50))))).forEach(async () => { | |
await engine.events.request2('pipeline:generateAll'); | |
engine.events.emit('outputDone'); | |
}); | |
ixBatch(ixFrom(contractsAndConfigs$.pipe(rxDebounce(() => rxInterval(50))))).forEach(async () => { | |
const contractsFiles = await engine.events.request2('config:contractsFiles'); | |
const [compiledContracts, contractsConfig] = await Promise.all([ | |
engine.events.request2('compiler:contracts:compile', contractsFiles), | |
engine.events.request2('config:contractsConfig') | |
]); | |
const [contractsList, contractDependencies] = await engine.events.request2( | |
'contracts:build', contractsConfig, compiledContracts | |
); | |
await engine.events.request2( | |
'deployment:contracts:deploy', contractsList, contractDependencies | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment