Last active
January 12, 2019 11:53
-
-
Save nclarx/ca4935f560f06bece827e83509a8888a to your computer and use it in GitHub Desktop.
Architecting
This file contains 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
import {MarkdownService, RendererService, FileSystemService, PuppeteerService, IngestService} from './services/_index'; | |
import {IWorkflowConfig} from './entities/_index'; | |
import {CommanderService} from './services/commander-service'; | |
import {empty, Observable, Observer, Subject} from "rxjs"; | |
import {IAppState} from "./entities/IAppStream"; | |
import {Command} from "commander"; | |
import {flatMap, mergeMap} from "rxjs/operators"; | |
const appState: IAppState = {}; | |
const cs = new CommanderService(); | |
const app$: Observable<IAppState> = Observable.create((obs: Observer<IAppState>) => { | |
obs.next(appState) | |
}); | |
const appRun = app$.pipe( | |
mergeMap( | |
(source) => cs.convertAction(), | |
(sourceValue, commandValue) => { | |
// console.log(sourceValue, commandValue); | |
sourceValue.command = commandValue.args[0]; | |
return sourceValue; | |
}) | |
); | |
appRun | |
.subscribe((data) => { | |
console.log('End result: ', data); | |
// Produces: End result: { command: './files' } | |
}); | |
// I want to substitute this for the second param in mergeMap() but not sure how... | |
const mergeCommanderToAppState = (appState: IAppState, commanderValues: Command) => { | |
appState.command = commanderValues.usage(); | |
return appState; | |
} | |
This file contains 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
import {IWorkflowConfig} from "./iWorkflowConfig"; | |
import {IMarkdown} from "./iMarkdown"; | |
import {Browser} from "puppeteer"; | |
import {Command} from "commander"; | |
export interface IAppState { | |
workflowConfig?: IWorkflowConfig; | |
template?: string; | |
styles?: string; | |
markdownFiles?: IMarkdown[]; | |
browser?: Browser; | |
command?: string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment