Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitors #12

Closed
gsimone opened this issue Aug 20, 2020 · 7 comments · Fixed by #35
Closed

Monitors #12

gsimone opened this issue Aug 20, 2020 · 7 comments · Fixed by #35
Milestone

Comments

@gsimone
Copy link
Collaborator

gsimone commented Aug 20, 2020

API for monitors, maybe a fn that hides constants or something

const  { mouseMonitor, x, y  } = useTweaks({ mouseMonitor: makeMonitor('2d'), x: 1, y: 1 })

// alt
const  { mouseMonitor, x, y  } = useTweaks({ mouseMonitor: { type: "MONITOR" }, x: 1, y: 1 })

useFrame(() => {
   mouseMonitor.set(mouse.x)

   // alt
  mouseMonitor(mouse.x)
})
 
@gsimone gsimone closed this as completed Aug 22, 2020
@CptCompiler
Copy link

hey @gsimone,
why did you close this issue?
Is there any way to use monitors?
Thanks. Nice work so far!

@dbismut
Copy link
Collaborator

dbismut commented Nov 4, 2020

Reopening! Pretty sure Gianmarco was already thinking of the new magic api he has in mind, but first things first!

@dbismut dbismut reopened this Nov 4, 2020
@gsimone
Copy link
Collaborator Author

gsimone commented Nov 4, 2020

Hey @CptCompiler we had them working in the previous API, but weren't too happy about it. Monitors are special in that they have to be imperatively set by the user, original API was something like:

const [monitor,setMonitor] = createMonitor(...)

useTweaks(monitor)

// your imperative code
setMonitor(4)

Opinions?

@gsimone
Copy link
Collaborator Author

gsimone commented Nov 4, 2020

@dbismut proposes using a ref, which we feel is more react-like

const ref = useRef(0)
useTweaks("Monitor", {
  ...otherTweaks,
  ...makeMonitor(ref, "MyMonitorName", ...settings))
}

// setting the ref value to update the monitor
useFrame(({ clock }) => { ref.current = Math.sin(clock.getElapsedTime()) })

@CptCompiler
Copy link

Thanks for your fast replies, guys!

Hmm... I think I would prefer refs as well. Sounds good.

@gsimone
Copy link
Collaborator Author

gsimone commented Nov 5, 2020

If you want you can give some feedback in PR #35

@gsimone gsimone mentioned this issue Nov 5, 2020
2 tasks
@gsimone gsimone added this to the v1 milestone Nov 6, 2020
@CptCompiler
Copy link

Yeah... thank you very much. Keep up the good work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants