Transcript#

This transcript was generated automatically and may contain errors.

Alright, so we are learning about irid today. We are here with Kyle Husmann. He works at Posit with me, but irid is actually his personal project. Kyle, would you like to introduce yourself? Tell us a little bit about yourself, and then we'll talk a little bit about Shiny.

Sure. Thanks for having me. So, as Libby said, my name is Kyle Husmann. I'm a software engineer here at Posit. I'm on the Workbench team, so I'm working on enterprise-facing stuff with like Workbench Pro, RStudio Pro, those kinds of things. Before that, I built a lot of Shiny apps, and I kept sort of, the more complex they got, the more I sort of started recognizing patterns over some of the limitations or some of the features that I wanted to see from Shiny, especially compared to other modern web frameworks like React or SolidJS. And so, with all of those ideas, I've developed irid, and I'm really excited to share what I've been working on with you all today.

Amazing. Okay, so we put a poll out both on Zoom, if you cannot get to Discord, and on Discord, if you are there, that is asking you what your familiarity with Shiny for R is. This is something I've been really curious about. We have more episodes coming up about Shiny in the future, some of them more beginner-level fundamental, some of them more intermediate and advanced, like testing in Shiny, which to me is like a whole other level that I am not very good at myself. So, I'm really excited to see where everybody is at.

So, what we are seeing so far, and Kyle, can you see that poll? I'm not sure if you can see it. You can, okay. Kyle is my co-host today, so I'm hoping he can see everything behind the scenes. We have about 2% of folks saying, I don't know what Shiny is. That's okay, you're going to find out. I'm so excited for you. I wish I could learn about Shiny for the first time again. About 35% on Zoom saying, I know what it is, but I've never used it. Again, so excited for you to learn more about it, and would love you to join us with Daniel Chen coming up in a future episode to learn about Shiny fundamentals. That's going to be fantastic. About 50% said, I have built Shiny apps, but I've never used Shiny modules. Shiny modules are kind of a modular way, as the name implies, to build Shiny apps, but they're just slightly an advanced topic, I think. And then we have about 13% of folks in Zoom saying, yep, I've built Shiny apps that do use modules, and I fall in that category as well.

And then if we go over to our Discord over here, we see slightly similar results, but we have a few more people who know what it is, but have never used it. So about 43% know what it is, but have never used it. And about 21% saying, I have used Shiny modules.

Okay, so here is what I am going to do. I am going to, just for anyone who is uninitiated, we're going to look at a Shiny app real quick, which means I'm going to move some stuff off of my screen. And I'm going to share my screen really quickly. And everyone can tell me if they recognize this dataset. This is the Iris dataset, our old standby. And thankfully, no live coding for me just yet, nor appreciate the candle. If you're new here, we like candles for live coding. And we flag questions with golf flags. So hey, if somebody asks a question, we don't have Isabella here today. Flag it for a golf flag with me if I miss it, okay?

Intro to Shiny reactivity

So we are going to be talking about interactivity and reactivity. This is a Shiny app. I'll make it bigger for you. This is the code that makes the Shiny app, and this is the Shiny app itself as it presents to the end user. Over here, we have a server.r and a ui.r. Ui meaning user interface. This is the front end. And server being the back end, just like you would have like server-side JavaScript. Okay. So our server-side stuff helps us calculate and do all the stuff under the hood, and the UI stuff helps determine what our end user is going to see.

When we are talking about interactivity, we're saying, hey, the user can click stuff, and they can make changes in our app, right? Let's change our number of clusters. And then when we're talking about reactivity, what we are talking about is the rerunning, basically, of our server code when something changes. We want our app to listen for the changes that we are making. So this app is completely reactive. When I change this, this also changes. When I change this, this also changes.

Shiny apps can get very, very complex very quickly, though, when you are adding a whole bunch of reactivity, and you're adding listening in different ways. For example, I could tell my Shiny app, hey, I want to change all these things, and then I want to press a button down here that says calculate. And I want you to hold all of your reactivity until I press that button to calculate, and then I want you to make all your changes.

Today, we are going to learn about irid. We are going to listen to Kyle briefly talk about the benefits of irid. And then if we need more examples, we're going to have Kyle show us lots and lots of code today. So everybody be very nice to us with our possibilities of live coding. All right, Kyle, I would love it if you could take it away.

And tell us a little bit about like, why? Why did you make irid? And what does it look like?

Building a simple Shiny app from scratch

Can everyone see my screen here? I can see it. Can everybody see the size? Okay. Sound off in Discord if you cannot see the size. I can make it bigger as well. Dave, Rodriguez, Trey, Julie, everybody says that they can see.

Okay, cool. So what I'm going to do is I'm going to do a lot of live coding here. So I need a lot of candles. I'll support your size, it could be like a skosh bigger, maybe like a command plus bigger. Yay. Okay, thanks.

Okay. Yes, I want everyone to be able to see here. So what I'm going to do is I'm going to first start with a put together a really simple shiny app. So I'll import this. So I'll import shiny. And then every shiny app has a UI and it has a server.

My server has an input and output and that session thing here and then I launch the shiny app. This is kind of move this down a bit. Watch the shiny app with shiny app. And then with my UI and my server here. Okay, so if I run this, it's not going to be very interesting.

I've run all these pieces. And Oh, actually, I don't even have any UI in here. So let's see if I can just Hello World. See if it lets me do that. restart my shiny app.

Okay, so here's my shiny app running. I don't have right now I just have a static UI that says Hello World. I have a server that's doing nothing. And then I have my shiny app launch it. Let's make this a little bit more complicated. I will add a let's let's add sorry my let's add bslib.

bslib if you haven't used it is a library for using bootstrap in shiny. So bootstrap is a formatting library that allows you to use things like page fluid. This will just give me better page elements. And I'm still working just in the UI here. In my UI, I can also add say, HTML tags. So if I add a tags, h1, this is big, this will get me a big HTML tag. And I promise I'm getting to irid, I just want to set up a nice base shiny app here so that we can have a comparison. So if I run this all again, this is big. Let's add a text box as well. So in shiny, that's a text input. And I I'd use a input ID. Hello, oops, every time someone joins it, I lose focus on my mouse here. So input my input and placeholder or label input.

And let's run this again.

Okay, and now I've got a text box over here, by which I can type text. Hello, world. And it's not doing anything because this is all going into the UI function. Now, let's say I want to add some reactivity here, I want to take whatever's in my text input, and then I want to display it under my text input here. So I will add that as well. I'll add a text output.

And let's see output ID, I believe that's what it is. Yes, output ID, my output.

And then so now I've got the output placeholder in my UI. And then I'm going to add the wiring in my server function to make the text output get rendered with the contents of my text input. So I'll say output my output.

I'm going to render text. And the text that I want to render is input my input.

Okay, let's all light a candle and hope this works.

Okay, hello. Oh, what do I got here? Sorry, my output my output.

This is where we all I didn't run the whole typo, or spot everything in discord like, ah, ah, press the button. Danny says a T is missing.

A T is missing. My where's the team? Ah, here it is my output. Well, actually, this is a really good illustration of why you're gonna like it.

So that mistake I made there was that my text ID, my output ID here was missing a text here, or a T here. And so then when I render that, let's just first verify it works. There we go. And it shows up on the bottom here. So a couple things you'll notice in shiny. So I've got this split between the UI that I'm building, and then the behavior that I'm wiring up, right.

And then whenever in order to connect the dots on that split, I have to write these IDs. And there's no, there's no notification. If I like to have a typo, like I just did, serendipitously, there's no notification that any of that happened. It's just it just drops that in the app over here.

If I like to have a typo, like I just did, serendipitously, there's no notification that any of that happened. It's just it just drops that in the app over here.

Introducing irid

So what I'm going to do is I'm going to switch over to a new window. And we'll do the same thing with the irid library that I've put together. And we'll see how it's different. So in irid library, let's, in irid, we don't have a UI function and a server function, we just have a single function that describes the whole app.

And then I have a similar to shiny app, I'm just going to say irid app, and then pass in that function. Inside this function, I'm going to describe what my app looks like. So this is, so let's start out just by in the same way that we started with our UI function here, I put together a page that had some text. Let's do the same thing here. Let's also import bslib. The bslib works with irid as well. And irid is built on shiny, which irid is built on shiny. Oh, sorry, go ahead. That stuff will work. No, I was gonna point out, we were gonna look at an irid app in just a second that is fully functioning and fleshed out. So everybody can get an example of that probably should have done that earlier. But irid is not only built on shiny, but it also plays nicely with shiny. So if you have a shiny app that's already built, you could use irid components and plug and play them. So keep that in mind while we're watching Kyle.

So here in my app function, if I just return a hello, like we did in the UI function here, we will get the simple shiny app that just has hello. Now let's add the page fluid. Page fluid. Let's add similar HTML tags. Oops.

And let's run this again.

Oh, syntax error. Forgot my comma.

Okay. Now let's add a text box. So my text, so this is where Irid departs from shiny. Instead of using text inputs and these types of controls that are from shiny, what I'm gonna do instead is just use a regular text input tag here. So this is just regular HTML. I'm gonna say type equals text, and I'll put a placeholder here. Enter text here. Oops.

So I'll go ahead and run this.

While you are running this, are you open to a question? Uh-oh. Can't execute code due to syntax error. While we figure out the syntax error, Daniel had asked, is this like implementing shiny for Python's express mode, but in R? Not quite. This is something closer to, if you've ever used ReactJS or SolidJS, these web frameworks, this allows you to write component functions that handle the UI and server reactivity for you.

So I'll show that in just one second here. So right now I've just put this text input on here, where now I also have a text box.

Right now my text box is not doing anything, because I haven't hooked up to any reactivity yet. So let's look at how we hook up reactivity. So in shiny, remember, we had our UI and server function. In my server function here, I have my text input and my text output, and then I'm creating this render text that pushes my input to my output. What I'm gonna do in Irid instead is create a single reactive value. So here's my text value. And I'm going to create a reactive value, just like we create reactive values in shiny. And I'm going to bind it to the value of my input.

And then what I'm going to do, instead of creating text outputs, in my app function here in Irid, we can just directly use this reactive value that we created. We can directly use it in our UI markup that we have here. So I'm going to put it here as text value. And then I'm going to go ahead and run this. Oops. Got an error here. Oh, oops. This should not be here. Let's try this again. So notice here I'm putting, instead of putting a text output here and then routing my input value into my text output value, I'm just directly putting this reactive value here, and that's giving me this setup. Hello, world. What am I missing here?

Value is text value. Did I run the whole thing?

Hmm. Text value.

It looks like it's working to me. What's missing?

Oh, there. I just didn't see. My Zoom window was covering up the text on the other side. So as you can see, when I put outputs here, this is automatically updating.

The power of Irid's reactive approach

So now you may be looking at this and you're like, okay, what's the point, right? Why do we take this whole other approach from Shiny in order to hook up our reactivity? The reason for this, the power behind IRID is that when we combine our UI and server functions, this gives us the ability to make any HTML tag reactive, or you can bind any reactive value inside any input inside any HTML tag. So let me just give you an example. Let's say in my input here, I want to add a style tag. This is just regular HTML. And let's assemble a style tag that gives me a color. And let's use the text value. And let's put that in a function. Okay.

Let's see what this does. So what I'm going to do is I have a style tag that's being created based on the value that's going into my text box. I run this whole thing. I was going to say, does that mean we could just type red and it'll be red? Yep. So type yellow, it'll be yellow. The other thing we can do is because these reactive values are driving the inputs, if I wanted to add another input here that gets the same value, if I do type equals text, value is text value. So what I've done, I've just added another UI element where I've assigned the value of that UI element to be that same reactive value that I've put in there. Let's go ahead and run this.

Oops. We have a question because someone wants to break it. What if you type something that isn't a color? Does it break or does it just ignore it? It just ignores it. So here's red. So you can see this text box is changing colors.

This text box is not changing colors. So first of all, if I wanted to do this similar thing where I'm making this text box change color and shiny, that starts getting difficult. I'm not sure actually off the top of my head, maybe this is a good puzzle for the crowd. I'm not sure off the top of my head how we would make a text box in shiny change color. I think you would have to make a custom text box or potentially start using shiny JS and start sending JavaScript events in order to do that. But I might be wrong there. I feel like I always go straight to CSS as the answer of changing the color of almost anything except for text. Yeah. So you could change the color with, you could have a CSS class and then you could use shiny JS to, you could use an observe and then you could have shiny JS add that CSS class or yeah, you could use shiny JS to push that style basically to your text box whenever you were trying to do that. But that's a little bit of a roundabout way of doing it. It just allows you to create, to compose your style tag in such a way that that just automatically updates. Similar with having these two text inputs get the same value.

This is in shiny, what we would have to do, we'd have a text input here with, well, I can just do that right here. If I say my input two, then what I would need to do is I'd need to have an observe here that will every time or that will update text input. Every time my input ID, I'd have to update my input one or my input with the value of input my input two. And then I would also, I'd need a similar observe for my other input in order to get those to talk to each other. It's not bad when you have just two inputs, but if you're putting together a big app that has like, you know, lots of tabs or that where you want to have multiple places for a user to input the same values, these update text inputs start getting pretty, pretty hairy because each of the, well, there's update text inputs, there's update slider inputs and stuff like that. It starts getting pretty hairy where all of these controls, because you can't drive them all from the same reactive value, all of these controls have to sort of chase each other. And you start getting these update circles where this, when you change this, it changes this other thing, which changes this other thing, which changes the first thing. And then you have to, it creates these cycles of updating where your app will sort of just be, get possessed and start working on its own. And you have to, and these can be really difficult to debug.

And you start getting these update circles where this, when you change this, it changes this other thing, which changes this other thing, which changes the first thing. And then you have to, it creates these cycles of updating where your app will sort of just be, get possessed and start working on its own. And you have to, and these can be really difficult to debug.

They can be. Actually, we want to debug something for our brains really quickly because David asked, hey, I always forget what that backslash and then parentheses do. And so on line 18, where we have the backslash, backslash, parentheses, he says, is it an anonymous function or a reference to the reactive value? Yes. So this is, this is an anonymous function. And so what, what this is doing is this is creating an anonymous function that will paste together the color and then the text value that's in our reactive value. And it dereferences the, the value here. So this, this actually gets the value of the reactive, but then it's all wrapped in this anonymous function. If we, if we took out this anonymous function, then this style would no longer be reactive anymore. So in Irid, the way you express a reactive value is by way of these, by way of giving a function that then Irid can call that function at any time this text value changes to get a new style that updates, if that makes sense. Yes, it does. And the parentheses after text value on line 18 for everybody as well is that is the reactive part of that, that reactive variable, the way that, that Kyle's calling it. Okay. Anonymous functions break my brain. So Dave, thank you for asking for clarification.

Comparing Shiny and Irid implementations

All right. So we have two different examples of trying to accomplish the same thing, right? Like one in Shiny and one in Irid. Do they work? Do, do, does do both of them work? I can't remember if we ran the Shiny app one. Oh yeah, we haven't, we haven't read the, we haven't ran the Shiny app. We can do that if we want. Let me, well, I'll just run it with the existing observe. So that is on there. So we, we don't have a way of changing the color like we have, but it looks, if I typed this correctly, then it looks like my input should be updated with the value of my input two. And it is.

I didn't set up the other way around. And so it's not updating the other way around.

But I want to show, so this is sort of the basic setting the scene. The, the Irid app include, or the, the Irid package has a bunch of examples that we can start looking at with our remaining time with sort of what, to, to see what's possible here. So let's look at Irid example.

If you run Irid example, just without any arguments, here's a big list of examples that are found in Irid. Let's do a really simple one. So let's start with. Just put one in the chat, by the way.

I just put one in the chat, by the way. I prompted you with the to-do list example. That's my favorite. Oh, OK. Let's look at a to-do list. So maybe not the least complex one, but my favorite. Because, and I will, yes, let's let Kyle bring it up here. This one's my favorite, because if you've ever had to build a Shiny app where you needed to add and subtract visual components that did something, like in this, this is a to-do app, so we all know what that does, right? We can check something off, we can add something that is a to-do, and we can remove it.

In my example, I've worked on apps where you are like, I need to add another file to submit. Maybe I have, my users have one file, or they could have six or seven or eight, and I need, they need to be able to add these extra like file submission boxes, and each one of them has to do a certain thing. That is so hard in Shiny. It's really, really complex. It's worth doing because you need the ability for your app to do it, but the way that Kyle is able to do this so much more fluidly is extremely impressive to me.

So I don't know if anybody out there has done this. Please let me know in Discord if you have built apps that need to add and subtract things like this, these visual components. Give us a tour of this app.

So here, and with this app, I'll say something, and then I'll add it to my to-do list,

and then you can see it populates this card below here. I can check a card and the thing will get crossed off. I can uncheck it. The thing will get uncrossed off.

I think this is a good example. I was mentioning how it's really useful to have a single reactive value, like drive multiple views of the same value. So here you can see we have all, we have active, we have done. These are, you know, the hello world here is a checkbox that is unselected. So this is a still active thing. That's why it's showing up on this list.

And we want that when we check this checkbox, well, it disappears from the active list, but now you can see it's on the done list. It's also still on the all list.

These checkbox, if you can imagine doing this in Shiny, synchronizing all of these pieces ends up getting a little bit difficult. You have to use a bunch of render UIs. You have to potentially use Shiny modules in here in order to handle these different cards and these different interactive controls that are embedded within each card.

So I have a little X button that will remove the card. And then let's see, if I select, if I look at all, if I select all of these things, say clear done, then it will show no to-dos yet, add one above.

Looking at the to-do app code

We can look at the code for this here. This is kind of hard to see on my screen. We might be, it might be challenging for us to look at the code and completely understand what it's doing, but I want everybody to just absorb what's possible right now, because there are other people in the chat who are like, oh yes, this is really challenging to do. I have tried to do this.

I'm glad Adam's here, Adam Hickard, who is one of our fellow positors as well, because he is a software engineering person, not a data science person like me. So my perspective is, oh, this is really challenging. Adam says, this is challenging in general.

We have a question from Jackie, if you're willing to take one right now. Yeah, here, wait, or yeah, go ahead. I'm just trying to work on copying this into this other window. Jackie's gonna be joining us soon on the data science lab as well to talk about testing in R, so I'm really excited about that.

But Jackie asks, can we build our own shiny inputs using HTML widgets? So we have a widget question. Yes, so I have a whole system called IRID widgets that gives you, lets you hook into the whole, to the lifecycle of an IRID app. And so that, so you can put together custom, you can put together custom widgets, which then work in IRID.

I have an example of this. Let me look at a IRID example. There's a CodeMirror widget. Which one is it called? CodeMirror. Okay, so this one embeds the CodeMirror editor in here.

And so you can see, here I am writing JavaScript in the CodeMirror editor. These are all controls that are within the, that are on the IRID page that allow you to then control the CodeMirror editor. You can see it tracks your cursor inside here.

This is much beyond the scope of our current conversation, but you can see in the same way that with HTML widgets, you can hook into the lifecycle of a shiny app. This is showing how you can hook into a lifecycle of an IRID app. And then in our actual app here, let's find the actual code editor. Here we go. So when we have the editor open, this launches the CodeMirror editor that we've wrapped with the IRID widget.

And then here's the actual reactive controls that we have hooked up to that. Another good example of an IRID widget is the Plotly. The Plotly one, let's look at actual Plotly. Oh, I need to install Plotly. Okay, let's try that again.

Okay, so here's a Plotly output. Let me try and, it's tough on this larger screen. So here I have a Plotly plot, and then I'm able to do things like select points. And down here, you can see the selection gets updated. And then I have buttons that can interact with the Plotly plot here. Let's say reset view, hide the eight-cylinder trace. I can select the sports cars.

My brain is breaking because it's going so fast. When I build apps and widgets like this, they take a little bit of time to do each thing. And also I can break them if I click around too quickly.

IRID's surgical update architecture

Right, yeah, so the difference in architecture between IRID and Shiny is that when you're doing this kind of complex reactivity in Shiny, you often have to, whenever you change something, you have to re-render the entire tag tree that goes in there. Yes, yeah, yeah. Right, whereas with IRID, it emits these surgical updates that only change whatever that specific tag is.

Right, whereas with IRID, it emits these surgical updates that only change whatever that specific tag is.

So you can have a, in Shiny, when I wanna change like this little thing over here, then it has to re-render the entire, you have to often re-render your entire universe in order to make that small change. Whereas with IRID, it will just surgically flip whatever that is and have that ready for you to go.

That is so freaking cool. Dave just said, I always get the error that I try to do something outside of a reactive context and my imprisonment is imminent. And like the straight to jail GIF is in my brain right now because I feel the same way.

Definitely, yeah. And so the nice thing about IRID is, I mean, you still can get that error, but usually when you get that error in Shiny, that's a sign that you need to move to a render UI or UI output. With IRID, and so then that's where you start getting these like large, these kind of slow rendering transitions and stuff like that.

With IRID, when you hit one of those points where it's, oh, you're trying to access this reactive outside of a reactive context, that usually just means, okay, you need to wrap your, what you're trying to do in a react in the anonymous function, the slash and parentheses. And then that will just start working automatically in IRID.

Amazing, okay. I totally interrupted you with looking at the code. Oh yeah, so let's look at the code here. Actually, let's look at one more example.

Temperature app: two controls, one reactive value

Here's the temperature app. So this is another example of two controls being driven by the same reactive value. I have a control that's in Celsius. I have a control that in Fahrenheit. In Shiny, like I said, like I mentioned at the beginning, if I was going to do this, I'd have to have the Celsius, or I'd have to have two controls here. And then when one changes, I have to update the other. And then when the other changes, I have to update the first. And so they're sort of chasing each other to try to make updates. In IRID, this is driven by a single, both controls are driven by a single reactive value. So you don't have to do that kind of circular chasing.

So let's go back and look at the to-do. And I wasn't able to copy this. I'm having trouble getting into the... I was going to try to copy this into my editor window, but this isn't copying for some reason. So let's look at the app.

So the to-do app here, like all IRID apps, it's just a function. I have a ID. This tells me what my current ID number is. And so every time I create a new to-do, I increment this ID by one. And then I have my list of to-dos here. These are just the to-dos that show up when you open the app. And again, this is a reactive value of a list of items.

Then this is the reactive value that holds the text input of what I'm currently typing as my new to-do. And then this filter right here is a reactive value that just says whether I've currently selected all active or done up here.

These are helper functions that allow me to add to-dos, remove to-dos, and then this is one that will tell me if which to-dos match a particular filter. So whether I've clicked all active or completed. Let's go down, and here's some more helper functions. Let's go down to the actual page that's being constructed. So in my page here, I have a bunch of cards.

So my controls at the top are just, that's this card up here. It's a card with a text box and an add button. So let's go down here and see what that looks like.

So here's my card, card body with, here's the text box, which is just an HTML input. And then here's the add button here. You can see I have the on-click of my button wired such that when a person clicks this, it runs the add to-do helper. So I have the add to-do helper up here. Like I said, it adds the to-dos to my list of what the person currently clicked. It increments to the next ID, and then it clears the text that we're looking at.

If I scroll down further, I get to the section where I have the filter tabs. Here, I have all active and completed, and then corresponding click events that allow me to change the filtering mode.

And then if I go down to the actual cards that are being written, here's the card sort of stack. And I have, this is a when function in IRID. This allows you to conditionally show part of your UI when a particular condition is true. So our condition is when the visible account is above zero, it will show all of the to-dos. When this condition is not true, it will show the no to-dos, the no to-dos left.

And you can see here, there's a nested when in here such that when you're in one of the filters, it will give you a no matching to-dos instead of no to-dos yet, add one above. We can actually test that up here. If I clear all my to-dos, no to-dos yet, add one above. Oh, I guess that's not, oh, no matching to-dos. So if I add one here, if I go to active or done, there's no matching to-dos because I have to-dos, but there's in this particular section, I don't have any matching to-dos.

Rendering each to-do with the each block

I think where it gets really interesting is where we render each of the to-dos. This is done inside this each block, which is also, which is, I mentioned, one of IRID's control functions. So it allows me to go through each of these to-dos and for each to-do, it's gonna run this anonymous function and it's either going to render the to-do when it matches the current filter that we're looking at, but yeah, it's either gonna render the to-do item when it matches the filter. Otherwise, it's just gonna render nothing. So you can see there's no otherwise in this when clause.

And so when it does render this to-do, it calls this to-do item function, which is just another function that accepts a to-do and then a function here that tells it how to remove a to-do.

The analogous setup here is in Shiny modules in the same way that you can invoke a Shiny module that's like a pocket of interactivity and reactivity. In IRID, instead of having to do this by a separate module system, this is simply, to create this component, it's simply just another function.

Let's look at that function. Here's my to-do item function. It accepts a to-do and then an onRemove function.

And so here's the to-do item that will render the checkbox as well as the contents of the to-do and then a X that onClick, it'll run the onRemove function. So this allows you by composing your items in this way, you can split off your app into components.

So like here, this is a very simple app. I realize it looks complex, but apps get really, really complicated. We have our main app component and then we have our to-do item component. And so our app is creating multiple instances of this to-do item component. And that's just as simple as calling the function of item for every to-do that we're currently looking at and then wiring up the onRemove items through.

So don't worry if you're not following the details of all of these pieces. This is where we're really diving in deep now. But the reason I'm sort of showing this is to kind of show where, at the beginning, I really showed the basics of IRID. And I think that the challenge is that you don't really start appreciating how those basics are serving you until you get to this level of complexity in your app, where, again, if you try to do this in Shiny, you start running into blocks.

You start sort of having to contort yourself in the app in a bunch of different ways in order to get this level of interactivity. But with the IRID approach, it's very straightforward and easy to maintain and troubleshoot.

But with the IRID approach, it's very straightforward and easy to maintain and troubleshoot.

Component-based design and modules

I agree. This is so super cool. We had a question from Dan that was a little bit earlier that is kind of on this. I think you just answered it. He said, component functions that handle UI server reactivity. That sounds like modules. And yes, that's what you kind of built for us right there, this reusable chunk that we can do different things with.

And I wanted to show one of my favorite examples besides the to-do list is the nested questions one. I think it's called nested each, which is so cool because it's one of those things where it's like a quiz builder kind of. There you go. So you can, that little add question button at the bottom. I cannot express how hard that is for me to do when I build things. So this is really, really cool.

All of these things have different options. You can even add options inside of the module that you just added, right? So like Kyle just added another question and then inside of that question, he's able to add more options. Just like when I build a poll in Discord or whatever, right? This has always been extremely hard for me to do in Shiny. And so this is really exciting for me that it's so easy to use as a user and it's pretty smooth and seamless. So I'm super, super impressed.

I wanted to make sure that we didn't have any questions that did not get answered. So if you are in the chat right now and you were like, I had a question and it didn't get answered, please let me know so I can make sure we go back and grab it. We're missing our amazing Isabella today who always makes sure that everything gets handled perfectly.

Why the name "irid"?

I wanted to ask you all as well from the beginning, but I didn't want to sidetrack us. Why did you call it Irrid? Irrid, I called it Irrid as short for iridescent. So it's like, so Irrid is built on Shiny, but it's this extra layer that sort of gives you extra Shiny. So it's, so you have, and actually I can show in the Shiny interop example, here is a, an Irrid app that's, or an Irrid component that is running within a Shiny app.

So if you look at my app.r, I have my counter UI, my counter server. These, this Shiny module that I've created is actually calling out to Irrid where it's, I'm rendering this Irrid component within my Shiny app.

So in order to use Irrid, you don't have to use, it's not like an all or nothing thing to adopt. You can have an existing Shiny app and then you can start running into this situation where, you know, oh, I need a bunch of cards, you know, one for each download. And I'm, you know, having trouble, you know, like I'm starting to hit these limitations that are coming in because of, you know, I'm trying to do this really advanced thing that's giving me a lot of problems. You can write that as an Irrid, you can write that as an Irrid component and you can just drop that into your Shiny app. You don't have to change anything else in your Shiny app, if that makes sense.

Converting existing Shiny apps to use irid

Amazing. Well, Amelia was asking something very close to this in the chat, which was, do you have any specific recommendations when you want to convert an existing Shiny app to use Irrid? Is it best to just build it back up from scratch or is there a good shortcut method? And she was saying, maybe that's what you're kind of saying right now is that you can just plug and play these components to make it easier.

I know that Irrid just hit CRAN. This is like a brand new thing. By the way, your hex is gorgeous. I love it. It's beautiful. Thank you. But, so I don't wanna like push you on like, do you have this and do you have that? But I was wondering if you had in your documentation things like any templates or advice on starting over or building or rebuilding or converting. Or maybe like skills for Claude or anything like that.

Yeah, I think skills for Claude is the next step because, yeah, with, I mean, right now what I'm doing, if I develop an Irrid app with Claude, I say, hey, Claude, look at the Irrid documentation to understand what it's about. And then put together this app for me. That would be a lot more efficient if I just turned that into a skill that had a compressed, like a compressed overview of Irrid's API and what an Irrid app looks like. So it could quickly just churn out, you could just describe the app that you wanted and then it would be able to write that immediately. So I don't have that yet, but I think that's kind of the next steps.

The question though, I think I realized that that was sort of a tangent. The question was about using this with existing Shiny apps. I think my advice there is if your Shiny app is working just fine, like there's no reason to convert it. I think the situation I built Irrid for is when you start reaching for these extra complex kinds of interactivity in your Shiny app. So if you know ahead of time, oh, I'm sitting down and I'm creating a Shiny app where I'm creating a Shiny app that's gonna have a bunch of user activity and I want the users to be able to save state and generate reports and have really advanced bookmarks, maybe that's something that you would wanna write with Irrid from the beginning.

But in general, if you're working in Shiny and then you're just like, oh darn, I wish I had a control that did X, Y, Z, before you start going down the rabbit hole of creating HTML widgets and a whole JavaScript library to accommodate that kind of interactivity, excuse me, Irrid is an option of doing that without even leaving the Shiny ecosystem.

Amazing. Amelia clarified, well, my app is not working just fine because we have lags and freezes on multiple clicks. I wonder if you're hitting that same thing that I usually hit when I'm building stuff like this, where I'm like, oh, I've clicked too much, I've broken it. And it just doesn't work as smoothly as Kyle's showing with Irrid, which is cool.

Definitely, that's like that moment where you're starting to get like refresh loops, where you click something and that changes something and it changes something and then your app is possessed, like I said. If you're hitting those, if you load your Shiny app, you click something and then this part locks up, that part locks up and then it has to wait and then you have to wait for everything to settle and then you finally get what you want. Or while that's happening, you click something else and then the whole app breaks. If you're starting to run into those situations, Irrid will relieve your pain.

If you're starting to run into those situations, Irrid will relieve your pain.

If you're just doing a regular straightforward, if you're doing a regular straightforward dashboard, Irrid is probably overkill for what you're doing. Irrid is targeted at folks that are making really complex, interactive production web apps.

Wrapping up

So cool. Well, we've reached the top of our hour, so we have to stop. However, I will say, go use Irrid. And Kyle, if people would like to ask questions, let you know about bugs, suggest things, is the GitHub repo the best place for that? Yes, please feel free to file issues in GitHub and feel free to reach out to me as well. My email's on my website.

I'm really excited to share this with you all and get feedback and hear from people that are using it. This is very experimental, so bear with me as we figure things out together, but I'm really, if this looks interesting to you if you've run into these kind of similar problems with these sort of similar glass ceiling with really, really interactive apps, I'd love to hear how you're using it and how it might be solving your problems.

Yeah, I look forward to a data science lab in the future where we feature several people who have built cool things with Irrid and we can have a show and tell, like an Irrid show and tell, that sounds really fun. So putting the challenge out for everybody. Okay, everybody, this was super fun. I'm so glad everybody joined us. Kyle, thank you so much. I hope you had a good time hanging out too. Yeah, yeah, this was a blast. Thank you so much for having me.