Last active
February 27, 2020 23:23
-
-
Save jwulf/5ffa03d23baa993635a69dd62ebe1e0f to your computer and use it in GitHub Desktop.
A code sample from the article http://joshwulf.com/blog/2020/02/functional-refactor
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
public async deployWorkflow( | |
workflow: ZB.DeployWorkflowFiles | ZB.DeployWorkflowBuffer | |
): Promise<ZB.DeployWorkflowResponse> { | |
const deploy = (workflows: ZB.WorkflowRequestObject[]) => | |
this.executeOperation('deployWorkflow', () => | |
this.gRPCClient.deployWorkflowSync({ | |
workflows, | |
}) | |
) | |
const error = (e: NEA.NonEmptyArray<string>) => | |
Promise.reject( | |
`Deployment failed. The following files were not found: ${e.join( | |
', ' | |
)}.` | |
) | |
return pipe( | |
bufferOrFiles(workflow), | |
E.fold(deploy, files => | |
pipe( | |
mapThese(files, readDefinitionFromFile), | |
E.fold(error, deploy) | |
) | |
) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment