Skip to content

Think through public API for Chaos component #2

@jchiatt

Description

@jchiatt

This is a first pass at what the API for Chaos could look like. Suggestions welcome!

<Chaos
  level={5}
  message="a custom error message"
  shallow
  depth={3}
  statelessOnly
  statefulOnly
  monkeys
  disasters={[
    "network",
    "language",
    "time",
    "location",
    "machine"
  ]}
>
  <SomeComponent />
  <AnotherComponent />
</Chaos>

level

This is a number (1-10) that allows you to set the likelihood of chaos occurring.

message

This is a custom error message you can pass in that will be displayed as the message when an error is triggered.

shallow & depth (Children & Nested Components)

Ideally, one should be able to wrap a single component, a component with children, or a component with grandchildren (possibly even their entire application), with Chaos.

It could have a depth prop that allows you to explicitly set the number of grandchildren to apply chaos to. It could also recursively apply chaos to all grandchildren unless you pass in a shallow prop, in which case chaos would only be applied to the immediate children.

statelessOnly & statefulOnly

These props would allow you to only apply potential chaos to stateless components or stateful components.

monkeys

This will be a special surprise. 🐒

disasters

This will allow you to specify the types of chaos that could occur. I think there will be a lot of new types in the future, but off the top of my head I thought about those listed. I think there's also potential for React-specific types of chaos, such as causing random re-renders and such, but only insofar that it mimics chaos that could actually occur in the real world.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions