-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support pipeable operators #11
Comments
I'm happy to implement this, but I'm not sure what a good way to achieve this would be. Manually import all known operators in the sandbox? AFAIK there's no good way to automatically import all operators without listing them explicitly. |
I'm not it's a good idea to pollute the global scope with all the available operators. You can just do: const { of } = Rx.Observable;
const { map } = Rx.operators;
const source$ = of(42);
source$.pipe(
map(value => 2 * value)
) |
In general I agree, especially considering that functionally there's nothing we can't do already. However, to provide some perspective, I've been using rxviz every day for a while now. I use I for my work, I use it for private work and I use it when answering questions on StackOverflow. The two issues I run into almost every time are:
Both can be worked around the way you describe, but it's just not as convenient as it could be for copy-pasting snippets in either direction. I guess one thing I could do is prepare a snippet which does all the global scope aliasing, save its URL and bookmark it to use it as my starter template. That might be good enough. |
@moroshko you should upgrade couple of examples to use lettable operators just to show this functionality. Prehaps add those already into comment block of the custom code page. This tool is awesome, thanks for this. |
@Airblader: rather that polluting global scope, I would expect something like quickfix command in editor that adds the imports. Maybe some visual toolbox, with all operators, creators etc. and their description would also help. |
@Liero That could be theoretically done using with keyword, but it is not recommended. And there is a problem that, there are non-ambiguous creators/operators. I would vote for import syntax. Imports are used in every app that uses RXJS, it solves ambiguities problem and is easily copy/paste able. |
Hello @Airblader , It's been a while but, as mentioned before, having them available in the global scope can be an issue, most notably with name clashes for things like However I can see how in its current state this is not very user-friendly. What do you think about: Short-termAutomatically turn import statements into their rxviz equivalent, e.g when pasting: import { combineLatest } from 'rxjs';
import { map } from 'rxjs/operators'; It becomes: const { combineLatest } = Rx
const { map } = Rx.operators Long-termThat would require far more work, but having something that provides auto-completion and adds imports should make the application far easier to use as an editor |
@rraziel For the long term, this should work https://github.com/cdr/code-server. Stripped down VSCode would work wonders... |
Closing #4 was a little premature. We can write our own pipeable operators and use them now, but due to the way rxjs is imported in the sandbox we cannot use all the built-ins as pipeable operators. For example, ideally this would work:
This would be really useful to quickly copy-paste samples from code you're writing to debug them as well as allow using rxviz as a reference for answers on platforms such as StackOverflow.
The text was updated successfully, but these errors were encountered: