Git Product home page Git Product logo

wiretap's Introduction

logo

Mobx Wiretap

The dev tool your mobx and mobx-state-tree app deserve

Wiretap

What's Mobx Wiretap?

Mobx wiretap is an electron app which allows you to inspect your mobx and mobx-state-tree states during development time. This makes debugging easy and fun.

Gitter chat

Features

  • Mobx
    • Live inspection of observable state
    • Update observable state
    • Listen to action logs
    • Invoke actions
  • Mobx state tree
    • Live inspection of state tree
    • View action, snapshot and patch logs
    • Apply snapshots and patches
    • Invoke actions with arguments
    • Record and replay actions

Getting started

1) Download the app

2) Install the npm module

yarn add mobx-wiretap --dev

3) Inspecting mobx observables

import { observable } from "mobx";
import { wiretap, inspect } from "mobx-wiretap";

// Provide a name as the app name.
wiretap("My awesome app");

const todos = observable([{
   text: "Watch narcos",
   completed: false
}])

// Now you are inspecting todos.
// Changes will reflect in real time in the app.
// First parameter is a required label.
inspect("Todos", todos);

4) Inspecting Mobx-state-tree observables

import { types } from "mobx-state-tree";
// Please note that you have to require from '/mst'.
import { wiretap, inspect } from "mobx-wiretap/mst";

// Provide a name as the app name.
wiretap("My awesome app");

const Todo = types.model("Todo", {
    title: types.string,
    done: false
}).actions(self => ({
    toggle() {
        self.done = !self.done
    }
}));

const todo = Todo.create({
    title: "Get coffee",
    done: false
});

// Now you are inspecting todos.
// Changes will reflect in real time in the app.
// First parameter is a required label.
inspect("Todo", todo);

Sometimes wiretap would not be able to auto-detect the actions from the mst observable you are tracking. In that case, you would be able to pass the action names as the third parameter as follows.

inspect("Todo", todo, ['addTodo']);

5) Inspecting plain object with log()

import { wiretap, log } from "mobx-wiretap";
wiretap("My awesome app");

// Call log
log("CustomObject", {
    question: "Are unicorns real?"
});

Examples

Connect to a specific port or a host

Wiretap usually listens on port 4000. If port 4000 is already occupied, wiretap would start listening on a different port. You can find the port in the sidebar.

If wiretap is listening on port other than 4000, you must provide the port when initializing. You could also provide a host.

import { wiretap } from "mobx-wiretap";
wiretap("My awesome app", {
    host: 'http://localhost',
    port: 84585
});

Mobx Wiretap Live (Experimental)

Mobx Wiretap Live is the same inspector but as a hosted app.

App: https://wiretap.debuggable.io/live/

Initialize with the peer id

All you have to do is install mobx-wiretap-remote and initialize your connection with the ID presented to you on https://wiretap.debuggable.io/live/

import { wiretap } from "mobx-wiretap-remote";
wiretap("My awesome app", {
    peerId: "<ID From https://wiretap.debuggable.io/live/>"
});

But if you are worried about sending your data to an unknown service, not to worry, your app data is NOT sent to a centralized server. Instead the app uses WebRTC - peer to peer connection and sends the data directly to the peer. So your app is a peer and the inspector tab is another peer.

FAQ

How does this differ from mobx-dev-tools?

Mobx-dev-tools is an awesome tool to inspect your react app and see how the UI reacts to state changes. Wiretap focuses more on the state itself. You would still need mobx-dev-tools to keep an eye on the react components.

The road ahead

  • Support for mobx computed properties.
  • Support for mobx-state-tree views.
  • Support for react native.

Looking for your suggestions

Let me know what you want to see in wiretap. Go right ahead and share your feedback and thoughts by creating an issue.

Contribute

  • Go into packages/app directory
  • Do yarn install
  • Run yarn dev to start the app

Inspiration

Inspired by Reactotron.

Thanks

Thanks Alex Bergin for the awesome loading animation.

License

MIT © Raathigeshan

wiretap's People

Contributors

itsjw avatar johnrees avatar martinvd avatar raathigesh avatar robinfehr 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

wiretap's Issues

Connection errors flooding the console if Wiretap is not running

If the desktop Wiretap is not running, the injected code keeps connect to the 4000 port every few seconds, and throws errors: (I'm using the recommended configuration)

mobx.js:6088 GET http://localhost:4000/socket.io/?EIO=3&transport=polling&t=MXO4aX6 net::ERR_CONNECTION_REFUSED

If I open the dev page for a whole day, the computer become very laggy due to the flooding error message.

Not sure if this is a bug report or support question. Any help would be appreciated!

Make host configurable

I'm running my mobx app in Docker. By looking at the source I can see that the host is hardcoded. localhost is not usable if app is running in docker container.

Please add host option to configuration.

time travelling

since there now is a undoManger - patchRecorder grouped by actions - we could add a proper time traveling to wiretap.
mobxjs/mobx-state-tree#504

though for wiretap we'd not only want to time travel the actions - reverse apply all patches of the action - but also be able to apply/ reverse-apply a single patch.

to do so we'd need to know if a patch within an action is applied or not, so in case he decides to undo a whole action when he already reverse-applied several patches of the same action, we'd know which patches are missing undo the whole action.

as discussed we could then also implement the UI like: (collapsible)

  • Action
    • Patch
    • Patch
    • Patch
  • Action
    • Patch
    • Patch
  • Action
    ...

and therefore disable the entires for the reverse applied patches/ undone actions.

snapshots should be separate since when applied we lose the actions and can only time travel for the following actions.

connecting to apps running HTTPS

Is there a way to configure wiretap to connect an app running HTTPS?

I have an app running HTTPS on port 4000, and when I try this:

wiretap('My App', {port: 49899});

...I get a lot of errors in my network console:

Mixed Content: The page at 'https://localhost:8443/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://localhost:49899/socket.io/?EIO=3&transport=polling'. This request has been blocked; the content must be served over HTTPS.

Several years ago I worked at Sencha and built a similar tool called Sencha Inspector -- we solved this by shipping with an SSL certificate, but considering you're building an open-source product I doubt that's a viable option here.

mobx-wiretap and mobx-wiretap-remote Not working with react-native

Mobx Wiretap desktop version 0.2.0 for Mac

package.json

"react-native": "^0.55.0",
...
"mobx-wiretap": "^0.13.1",
"mobx-wiretap-remote": "^0.3.0",

I see the PORT is 4000 and can see the polling request to PORT 4000 but nothing shows up in the wiretap app.

import { wiretap, log } from 'mobx-wiretap'

wiretap('App Name', {
  peerId: '03733bf1-d79b-412a-a9e8-1b3badf38fe9'
})
log("CustomObject", {
  question: "Are unicorns real?"
})

The same code above using mobx-wiretap-remote in place oа 'mobx-wiretap' I get an error.

Error messages:

[Unhandled promise rejection: TypeError: undefined is not a function (evaluating 'global.postMessage(messageName, '*')')]
- node_modules/mobx-wiretap-remote/mobx.js:1314:25 in setZeroTimeoutPostMessage
- node_modules/mobx-wiretap-remote/mobx.js:9157:22 in _delayedAbort
- node_modules/mobx-wiretap-remote/mobx.js:8870:23 in Peer
- node_modules/mobx-wiretap-remote/mobx.js:8773:66 in <unknown>
- node_modules/promise/setimmediate/core.js:45:7 in tryCallTwo
- node_modules/promise/setimmediate/core.js:200:23 in doResolve
- node_modules/promise/setimmediate/core.js:66:12 in Promise
- node_modules/mobx-wiretap-remote/mobx.js:8772:21 in peer
- node_modules/mobx-wiretap-remote/mobx.js:1838:81 in initialize
- node_modules/mobx-wiretap-remote/mobx.js:10422:73 in wiretap
* src/App.js:10:8 in <unknown>
- node_modules/metro/src/lib/polyfills/require.js:214:12 in loadModuleImplementation
- node_modules/metro/src/lib/polyfills/require.js:148:36 in guardedLoadModule
- node_modules/metro/src/lib/polyfills/require.js:132:20 in _require
- node_modules/react-native-scripts/build/bin/crna-entry-web.js:7:11 in <unknown>
- node_modules/metro/src/lib/polyfills/require.js:214:12 in loadModuleImplementation
- node_modules/metro/src/lib/polyfills/require.js:141:45 in guardedLoadModule
- node_modules/metro/src/lib/polyfills/require.js:132:20 in _require
* null:null in global code

Initializing a property that is an Observable array of string causes "[mobx] Invariant failed: Cannot obtain administration from string 1" error

Working example:

https://codesandbox.io/s/7j2147k0lj

Adding an array of strings to a store causes an "Invariant failed" error and stops loading the application when Wiretap is used.

2018-10-30 16_29_07-simple mobx todolist - codesandbox

Commenting out the someArray declaration avoids the error

class TodoList {
  @observable todos = [];
  // comment this line to avoid the error
  @observable someArray = ["string 1", "string 2"];
  @computed
  get unfinishedTodoCount() {
    return this.todos.filter(todo => !todo.finished).length;
  }
}

Linux support

First of all, thanks for such a tool, it looks awesome.
In our teams we are mostly using Linux 64 bit and we would love to start using this tool. Are there any plans to add Linux support ?

apply snapshot after reload

first of all - cool project!

feature request:
it would be actually very cool if we could apply snapshots after a reload - save snapshots/recordings and apply them even after a reload.

use case:
in a more complex app, for example, we have to execute multiple actions to reach the actual state where the feature - the one we're currently working on - can be retested.

Not seeing actions for MST Store

Under the actions pane, I'm seeing This observable does not have any actions associated. These are all singleton MST stores, so they are already instantiated. All of the stores are showing up as expected, just missing actions.

Let me know if I am missing anything.

import UiStore from 'stores/UiStore';
import NavigationStore from 'stores/NavigationStore';
import ReceivingStore from 'routes/receiving/ReceivingStore';
import CarriesStore from 'routes/carries/CarriesStore';

const { wiretap, inspect } = require('mobx-wiretap/mst');

wiretap('My App');

inspect('UiStore', UiStore);
inspect('NavigationStore', NavigationStore);
inspect('ReceivingStore', ReceivingStore);
inspect('CarriesStore', CarriesStore);

TypeError: Cannot read property 'isMobxAction' of null

On one of my store I'm getting the following error:

TypeError: Cannot read property 'isMobxAction' of null

However, I can't see what in my store wiretap is having problems with. I've made sure I'm on the most up to date version of Mobx, anything I can do to debug?

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.