curran / curran/d3-rosetta

Real World Unidirectional Data Flow Utility

Open
#35 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7
Forks
0
PR merge metrics
No merged PRs in 30d

Description

The current implementation is minimal for textbook examples:

```js
export const unidirectionalDataFlow = (container, viz) => {
let state = {};
const setState = (next) => {
state = next(state);
viz(container, state, setState);
};
viz(container, state, setState);
};
```

An implementation like this could prove more useful for actually wrapping the implementations, untouched, in various frameworks, by providing integration points for:

* Initializing the state
* Receiving notifications for state updates
* Cleaning up side effects on unmount
* Hot reloading

```js
export const unidirectionalDataFlow = ({
container,
viz,
onStateChange,
initialState = {},
}) => {
let state = {};
let unmount = () => {};

const setState = (next) => {
state = next(state);
onStateChange(state);
unmount = viz(container, state, setState);
};

setState(() => initialState);

return {
setState,
unmount: unmount,
hotReload: (newViz) => {
unmount();
viz = newViz;
unmount = viz(container, state, setState);
},
};
};
```

I'll wait until there's an actual need for each piece before adding to the library. Please drop a comment here if you're interested in any of this!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the unidirectionalDataFlow entry point and the current implementation shown in the issue. First establish which integration point is actually needed; completion depends on an agreed scope and corresponding implementation, since the issue currently proposes several possibilities without selecting one.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.