switz / driver

🏁 A typescript package for declarative finite states and commonly derived values - zero dependencies, fully typed, & framework agnostic
https://npmjs.com/package/@switz/driver
MIT License
114 stars 1 forks source link

Multiple nested states #5

Open switz opened 1 year ago

switz commented 1 year ago

Very often we have multiple boolean flags to represent a component and a single finite state does not reflect the UI we want to build. How might we design a more flexible driver to handle nested finite states?

const card = driver({
  states: {
    USER: {
      ADMIN: isAdmin,
      MEMBER: isMember,
      LOGGEDOUT: true,
    },
    CARD: {
      IS_DELETED: card.status === 'deleted',
    }
  },
});

Jotting down some notes, need to think more here.