DEV Community

Discussion on: My beloved React micro frontends 😍

Collapse
 
bitttttten profile image
bitten

What does chan, Zone, inst, and Service do?

Collapse
 
betula profile image
Slava Birch

Hi, bitten!
Thank you for your interest!
And thanks a lot for your feedback. With your help I made some several changes in library external interface:

  • I renamed chan to call because its interface for a remote (between zones/services) async call.
  • I removed inst keyword, and you can see a fresh example at realar github readme, now you can use unit as a factory now:
const todo = unit({
  items: [
    { title: 'Todo 1' },
    { title: 'Todo 2', completed: true }
  ],
  get completed() {
    return this.items.filter(i => i.completed);
  },
  get all() {
    return this.items;
  },
  add(title, completed = false) {
    this.items = [ ...this.items, { title, completed }];
  },
  toggle(i) {
    const { items } = this;
    const index = items.indexOf(i);
    this.items = [
      ...items.slice(0, index),
      { ...i, completed: !i.completed },
      ...items.slice(index+1)
    ];
  }
});

const panel = unit({
  todo: todo(),
  sidemenu: [],
  get todos() {
    return this.todo.all;
  },
// ...
  • What about Zone. It's a little bit difficult for answering in comment here and need some time for me, for prepare a good answer for that very important moment.

Cheers,