cheatcode / joystick

A full-stack JavaScript framework for building stable, easy-to-maintain apps and websites.
https://cheatcode.co/joystick
Other
209 stars 11 forks source link

Consider adding a state option to get() and set() in joystick.js/ui #339

Closed rglover closed 1 year ago

rglover commented 1 year ago

I routinely want to track whether or not I'm running a get() or set() in the UI on state so I can handle things like disabling buttons. Purely for convenience, it'd be helpful to have a state option that can be set to the name of a key that resolve to true or false when a get() or set() is run. This would automatically set state behind the scenes for you w/o the need for extra code.

rglover commented 1 year ago

Added to canary. API required passing the component instance in (get() and set() are standalone functions and don't have direct access). Clean enough and works well:

set('connect_vultr', {
  input: {
    api_key: event?.target?.api_key?.value,
  },
  loader: {
    instance,
    state: 'connecting_vultr',
  },
})