
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
mobx-server-wait
Advanced tools
Render universally with server wait mobx actions.
Think of the scenario where you want to do some work in a promise. Once the work is complete, render the webpage.
npm install --save mobx-server-wait
store.js
:import { observable, extendObservable, action } from 'mobx';
import serverWait, { fillServerWait } from 'mobx-server-wait';
import fetch from 'isomorphic-fetch';
class Store {
constructor(state = {}) {
extendObservable(this, state);
fillServerWait(state, 'serverWaitKeyToUse');
}
@observable
planets = {
isLoading: false,
data: [],
};
@serverWait
fetchPlanets() {
this.planets.isLoading = true;
const data = fetch('https://swapi.co/api/planets')
.then(res => res.json());
.then(action(data => {
this.planets.isLoading = false;
this.planets.data = data.results;
}));
}
}
server.js
:import express from 'express';
import { serverWaitRender } from 'mobx-server-wait';
import store from './store.js';
// Assuming you've created your server with express
app.get('*', (req, res, next) => {
const store = new Store();
const root = (
<Provider planets={store}>
<App />
</Provider>
);
const render = (html, store) => res.send(`
<!doctype html>
<html>
<body>
<div id="root">${html}</div>
<script>window.__STATE__ = ${store};</script>
<script src="/bundle.js"></script>
</body>
</html>
`);
const storeKey = 'serverWaitKeyToUse';
serverWaitRender({ store, storeKey, root, render, onError: next });
});
{
// Maximum wait time for individual action
maxWait: <Number> || -1,
// Retry rejected promise actions on the client
retryRejected: <Boolean> || false,
}
{
// Maximum waiting time until the server calls the render method.
maxWait: <Number> || 1250,
// Attach debugger like debug: (...args) => console.log(...args);
debug: <Function> || undefined,
// React component as root
root: <React.Component> || undefined,
// Handled errors
onError: <Function> || undefined,
// The mobx root store
store: <Object> || {},
// Render method
render: <Function> || (html, state) => {},
// Unique key to store promises map
storeKey: <String> || 'serverWaitPromieses',
}
MIT
FAQs
Render universally with server wait mobx actions.
The npm package mobx-server-wait receives a total of 0 weekly downloads. As such, mobx-server-wait popularity was classified as not popular.
We found that mobx-server-wait demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.