Code Monkey home page Code Monkey logo

rxviz's Introduction

RxViz logo

Project Status

Looking for maintainers!

Unfortunately, I don't have the time to maintain this project anymore. If you are interested to help, please reach out to me on Twitter @moroshko.

Description

RxViz simply visualizes a given Observable. Your JavaScript code will be evaluated, and, if the last expression is an Observable, a nice animated visualization will appear.

You can also:

  • Control the speed of the animation by modifying the Time window input.
  • Copy the resulting SVG to include in your next Rx presentation.
  • Share the visualization with your friends.

Examples

Basic interval

rxviz-basic-interval

Random error

rxviz-random-error

Higher order Observable

rxviz-higher-order-observable

Pause and resume

rxviz-pause-and-resume

How does it work?

RxViz treats the evaluated Observable as a black box. We rely only on the fact that Observable emits values over time. RxViz doesn't rely on the internals of RxJS. This will allow us to visualize TC39 Observables in the future.

Technically, we subscribe to the given Observable, and, once a value is observed, we simply add it to the visualization. It's that simple!

How about higher order Observables?

No different. Since a higher order Observable is simply an Observable whose values are Observables themselves, we just repeat the process recursively.

When an Observable value is seen, we subscribe to it. At this point, we create a new "branch" in the visualization.

Thanks

Running locally

npm install
npm run dev

rxviz's People

Contributors

airblader avatar dependabot[bot] avatar moroshko avatar rakannimer avatar rraziel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxviz's Issues

Deployment broken.

Next to #5, the website is now down entirely. It seems this project is abandoned, so I have little hope; but it's really a shame. This website was extremely useful.

For anyone finding this, luckily cloning and npm install && npm run dev makes it work locally without a problem.

Support pipeable operators

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:

const source$ = of(42);
source$.pipe(
  map(value => 2 * value)
)

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.

Snippet disappeared

I created a snippet and saved it, giving me the link xOvAwvo2. The snippet worked at first, verified by the fact that the person asking this question was able to see the snippet, so it's also not an issue of copy-pasting the wrong link etc.

However, now (a couple minutes after creating it), the link just 404s for me. The same happened with another snippet I made in response, and that one I double-checked that the copied URL worked.

Seems like mysterious things are going on here.

Share link not working

I get the following:

NET::ERR_CERT_DATE_INVALID

This server could not prove that it is api.rxviz.com; its security certificate expired 27 days ago. This may be caused by a misconfiguration or an attacker intercepting your connection. Your computer's clock is currently set to Friday, April 26, 2019. Does that look right? If not, you should correct your system's clock and then refresh this page.

A recurrence of Issue #5

Clean feature requests

There seem quite a bit of request, that are already done. Could we clean it up? I would help, if I can.

Ability to use json-server for persisting snippets

I cloned and run the service on port:3000.
I saw that it tries to save the snippets on port 4000, so I started a json-server with a default db {snippets:[]}.

Snippets entries are created with id 1,2,3... but the code is not present.
I also see this when clicking on visualize which might be related to not being able to save the code:

Warning: Failed prop type: Invalid prop `shareId` of type `number` supplied to `_class`, expected `string`.
    in _class (at index.js?entry:182)
    in _class (created by Container)
    in AppContainer (created by Container)
    in Container (created by App)
    in div (created by App)
    in App

Current entries on http://localhost:4000/snippets/

[
  {
    "isShared": true,
    "id": 1
  },
  {
    "isShared": true,
    "id": 2
  },
  {
    "isShared": true,
    "id": 3
  }
]

Would be nice to fix this or propose any other back-end for snippets.

FYI: As a workaround I tried to run json-server with shareId as identifier:
json-server -p4000 -w db.json -i shareId
In this case, every new snippet is saved on the server when I press visualize.
For some reason I cannot see the share link button, but if I manually get the newly created shareId then I can visualize correctly (e.g. on http://localhost:3000/v/4 )

Share link doesn't work

It seems like Share link functionality doesn't work.

It would be better to be able to persist something like upload in a github gist in the playground

Sharing snippets doesn't work anymore (again)

My snippets all mysteriously disappeared, despite creating them after #12. And as of now, clicking the share button results in a "Failed" status.

This is really quite annoying – after #12 I had to recreate a couple dozen snippets for a presentation and now they're all gone again. :-( Why not just base64 encode the code + time window instead of storing the snippet in the backend?

forkJoin fails when given a dictionary/object despite the RxJS documentation saying it can handle that

So, if you look at the first example for forkJoin at https://rxjs.dev/api/index/function/forkJoin it mentions using a dictionary of observable inputs. If I try to use that forkJoin example with RxViz, though, it shows a failed Observable with the tooltip being You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array or Iterable.. It would be nice if RxViz could support passing a dictionary into forkJoin (or maybe any other functions that also could take a dictionary, but I don't know what others are like that offhand).

Update custom operator example

I think the custom operator example should be rewritten to use pipeable operators instead of mutating the prototype:

const sqrt = source$ => Rx.Observable.create(observer =>
    source$.subscribe(
      value => {
        const result = Math.sqrt(value);

        if (typeof value !== 'number' || isNaN(result)) {
          observer.error(`Square root of ${value} doesn't exist`);
        } else {
          observer.next(result);
        }
      },
      err => observer.error(err),
      () => observer.complete()
    )
  );

Rx.Observable
  .interval(1000)
  .pipe(sqrt)

Server down :(

Hi, loving the tool and integrating it into my daily use, but looks like the server is down :(

screen shot 2017-10-20 at 15 36 03

Visualize multiple observables at the same time

Hello!

Thank you for this great tool, it's really amazing!

However, it would be nice if we could be able to visualize multiple observables on a single screen in parallel.

Having this example:

const { interval } = Rx;
const { map, take, filter } = RxOperators;

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const numbers$ = interval(500).pipe(
  take(10),
  map(index => numbers[index])
);

const oddNumbers$ = numbers$.pipe(filter(number => number % 2 === 1));
const evenNumbers$ = numbers$.pipe(filter(number => number % 2 === 0));

[numbers$, oddNumbers$, evenNumbers$];

We should be able to visualize all three observables. This would be great to see how different transformations work (like in marble diagrams).

Share link not working

A "Failed" message shows up when I try to share.

On the console, I get this message: "Fetch API cannot load https://api.rxviz.com/snippets. The certificate for this server is invalid. You might be connecting to a server that is pretending to be “api.rxviz.com” which could put your confidential information at risk."

flatMapLatest not working

Hey! I can't seem to get flatMapLatest working (the console says it's not a valid function)

Sample code:

 Rx.Observable.create(observer => {
  setTimeout(() => observer.next(1), 500)
  setTimeout(() => observer.next(2), 2500)
  setTimeout(() => observer.next(3), 4500)
}).flatMap ( number => {
  return Rx.Observable.create(observer => {
	setTimeout(() => observer.next(number), 500)
	setTimeout(() => observer.next(number * 2), 1000)
	setTimeout(() => observer.next(number * 3), 1500)
  })
})

Simple example of higher order Observable not working

Nice project! However a simple example like this does not work on your rxwiz workbench:

Rx.Observable
  .interval(1000)
  .map(n => Observable.of(1))

(the result of the above example should show a lot of branches with a single emitted item of 1 on each branch)

This example also fails:

Rx.Observable
  .interval(1000)
  .switchMap(n => Observable.of(1))

(should show single observable stream emitting an item of 1 every second)

Both example only provide an empty stream terminating after 1 second.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.