Skip to content

Instantly share code, notes, and snippets.

@roytouw7
Created August 20, 2020 12:42
Show Gist options
  • Save roytouw7/64c00c61dc26a0150793f32c24dad971 to your computer and use it in GitHub Desktop.
Save roytouw7/64c00c61dc26a0150793f32c24dad971 to your computer and use it in GitHub Desktop.
// Classify node, dispatch to appropriate wrapper function.
export const dispatch = (node: Touched<ts.Node>): [Transformed<ts.Node>, RxJSPart] => {
const classification = classify(node);
switch (classification) {
case RxJSPart.observable: {
const transformed = markAsTransformed(wrapObservableStatement(node as ts.CallExpression));
return [transformed, classification];
}
case RxJSPart.subscriber: {
const transformed = markAsTransformed(wrapSubscribeExpression(node as ts.CallExpression));
return [transformed, classification];
}
case RxJSPart.pipeOperator: {
const transformed = markAsTransformed(wrapPipeOperatorExpression(node as ts.CallExpression));
return [transformed, classification];
}
default:
return [node, classification];
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment