Last active
March 26, 2020 08:25
-
-
Save LironHazan/29881db19edfa10777bce94f62bbf534 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
class FunWithFunctionalTS { | |
queryEditorState: Readonly<QueryEditorState>; | |
static updateEditorState( | |
editorState: Readonly<QueryEditorState>, | |
sliceToUpdate: Partial<Readonly<QueryEditorState>> | |
): Readonly<QueryEditorState> { | |
return { ...editorState, ...sliceToUpdate }; | |
} | |
updateEditorOnParseResult(result: Partial<ParseTextResult>): Partial<ParseTextResult> { | |
this.queryEditorState = FunWithFunctionalTS.updateEditorState(this.queryEditorState, { | |
valid: result.isValid, | |
textTokens: result.tokenList | |
}); | |
return result; | |
} | |
doSomething() { | |
// g after f LOL | |
const result = this.updateEditorOnParseResult(this.parseEditorText(this.queryEditorState.text)); | |
console.log(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually it will be better if the
updateEditorOnParseResult
will be void - in this example I just wanted a one line composition in practice I'll split it..