jonthegeek,
@jonthegeek@fosstodon.org avatar

My most useful #RShiny epiphany: modules are a convenient fiction. If you need a way to access a particular input from "inside" a module, there's nothing stopping you from making another module server function just for that. Or you can just NS() to get it, but it's cleaner if you wrap it up, and that generalizes out to more complex sets of functionality related to your module. #RStats

grrrck,
@grrrck@fosstodon.org avatar

@jonthegeek I have a half-written blog post (in my head) titled “Shiny modules can return anything”. For me that was also an epiphany-level realization that makes some patterns so much easier than I previously made them

jonthegeek,
@jonthegeek@fosstodon.org avatar

@grrrck yeah, I have a whole bunch of things I want to refactor now! I have a couple more things to fix in my mental model before I do TOO much work, though, so I might have some questions on shiny discord in a bit 😊

grrrck,
@grrrck@fosstodon.org avatar

@jonthegeek I really like your “useful fiction” line btw, it’s so true.

jonthegeek,
@jonthegeek@fosstodon.org avatar

@grrrck Yeah, I guess the big epiphany was really "moduleServer() is just a wrapper to deal with namespacing, it's not doing anything magic!" I don't think that's really possible to understand until you get a handle on the fact that everything in the server function is being added to the same session, no matter where that session is. The non-functional nature makes it confusing when you're used to the rest of #RStats.

grrrck,
@grrrck@fosstodon.org avatar

@jonthegeek I also think it’s confusing that you do something special to the input ids in the UI but not in the server. I think we fixed that incongruity in Shiny for Python so you don’t need to ns() the input ids

grrrck,
@grrrck@fosstodon.org avatar

@jonthegeek but the functional confusion also gets me often when writing modules. Without modules it’s easy to connect inputs and outputs as you go. I often find I get the “boundary“ of my module wrong and immediately want it to connect to other elements or modules in non-local ways. If you think very functionally, you end up changing what’s passed into the module. But the return anything method I epiphanied into lets you have both a functional wrapper and non-local connections

jonthegeek,
@jonthegeek@fosstodon.org avatar

@grrrck And after this conversation... I've realized the specific use-case I had in mind doesn't need anything extra; I really just need to return a single reactive after setting up observers and whatnot. It's still hard to grok "You can do the observer stuff but then ALSO return a value 'cuz the observers don't need to be 'returned' per se."

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • GTA5RPClips
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • tacticalgear
  • cubers
  • Youngstown
  • mdbf
  • slotface
  • rosin
  • osvaldo12
  • ngwrru68w68
  • kavyap
  • InstantRegret
  • JUstTest
  • everett
  • Durango
  • cisconetworking
  • khanakhh
  • ethstaker
  • tester
  • anitta
  • Leos
  • normalnudes
  • modclub
  • megavids
  • provamag3
  • lostlight
  • All magazines