Hacker News new | ask | show | jobs
by kennyfrc 953 days ago
Thanks! Cami is technically a combination of both. I like the intuitiveness of observables so that’s used:

```

// define observable

this.count = this.observable(0);

// getting

this.count.value;

// setting

this.count.update(value => value + 1);

```

But it also has a redux-like pattern where you can dispatch actions and register reducers with far less ceremony:

```

// define store

const todoStore = createStore({ todos: [], });

// register reducer / producer

todoStore.register('add', (store, payload) => { store.todos.push(payload); });

// subscribe component to store

this.todos = this.subscribe(todoStore, 'todos');

// dispatch

this.dispatch("add", newTodo);

```

It looks like it’s mutating, but both the reducers and update() uses immer* under the hood, so we still respect immutability under the hood.

Cami supports redux devtools so you can use that for time-travel debugging too.

—-

* https://github.com/immerjs/immer

1 comments

> this.dispatch("add", newTodo);

Will the V8 JIT optimize the hash based function table loop into a constant integer array lookup?