07:55Yeah, that happens all the time.
07:57I think that's one of the reasons
why it took off, is because it's very
07:59pragmatic, for the slop that most
people are working with every day.
08:04Whether that's your own slop,
hopefully you've been in your job
08:08long enough to have to deal with your
own slop, or it's slop from before,
08:13or you're just moving so fast that.
08:15That's just what it is.
08:16But, but the reality is that, you
know, things are just messy, when
08:21you're shipping real products to
real people as fast as possible.
08:24and I built React Query 'cause I needed a
way to make the experience better for, for
08:31developers and users without needing to
get in the middle of the entire process.
08:38like Meteor was trying to do,
or like GraphQL was trying to do
08:42or Apollo, you know, I needed as
little buy-in as possible with
08:46the maximum amount of, effect.
08:48And, that's what it came to be
and I think it's very natural.
08:53when you start playing with Query,
you start to realize that it is
08:58in a way, a sync engine, right?
09:00You have defined these declarative.
09:03subscriptions to your data,
it's very manual, right?
09:08Very, course brain manual timings
of like, how often do I want
09:12to go and get this thing right?
09:14So it's in the middle of like a
one-off, API call and a sync engine.
09:19but it is living and breathing
and, the life cycle of that life
09:26in this, Query cycle still takes
some effort from users, you know?
09:30So when you change something, you
need to let Query know, that you've
09:35changed something at the very least.
09:37And we call that this invalidation, right?
09:39And this is kind of like the bare
minimum for What I would call
09:44probably the worst sync engine you
could want is just like, I've changed
09:49something, invalidate everything
and just re-sync everything, right?
09:53It's, it's very manual.
09:54You are the one deciding when to re-sync.
09:57And it turns out that a lot
of developers just weren't
09:59doing that in the first place.
10:01so it's crazy to think that just teaching,
giving people a good tool, like Query
10:07and then telling them, Hey, when you
change something, you need to just
10:10mark everything as dirty and re-sync.
10:14It.
10:14Just, that has improved
everybody's apps a ton.
10:20And user apps, you know, it's
like, oh, data is up to date.
10:24You know, it's not super efficient, it's
not automatic or whatever, but it is.
10:28so I think that's, the bare minimum,
and that's the reality where a lot
10:31of developers are today is they're
probably still coming, they may even
10:37be coming from .net or, you know, some
monolithic backend shop into front
10:44end, and they've never done any front
end syncing, data syncing at all.
10:49And they might just think, well, I'm just
gonna call my API and display the data.
10:52Right?
10:53So I think that that's the
reality for most developers.
10:57Most, successful companies are not running
the latest and greatest, and many of
11:02them probably don't even know, you know,
the first thing about designing a sync
11:06engine, I barely know anything about them.
11:09So I, I wouldn't expect many, you
know, many of your run of the mill
11:13developers to know a lot about it either.
11:15So, but I think that's the first step.
11:18And I, I think personally that once
you taste that, it's addicting.
11:22You want more of that and you
naturally start to say, okay,
11:26how can I make this faster?
11:27Right?
11:27And that's on the read's end, which
is kind of like the bare minimum.
11:30It's like, I wanna read my data
and make sure it's up to date.
11:34And then you start thinking about the
writes and you're like, oh, well you know
11:36what would be cool is if when I click
this button it just showed that it's done,
11:42even though we know it takes, you know,
a hot second for it to go and be done.
11:47And then to resync all the
data, it'd be cool if it was
11:50just looked like it was done.
11:52And so we call that an
optimistic update, right?
11:55Like optimistic, data manipulation
and Query has that built in.
11:59Again, it's very manual.
12:01you have to manipulate the cache that's
in your browser, in the Query client
12:07to represent that new state manually.
12:10and you fire off the mutation
or, the change that's going
12:13to result in that state.
12:14And then you just kind
of cross your fingers.
12:16That when you invalidate your
data, when it's done and that new
12:19data comes in, it matches what
you optimistically put in there.
12:23Again, this is like from my perspective,
if you can implement optimistic
12:29mutations with something like Query,
you're already so much further ahead
12:33than what the standard has been
for a very, very, very long time.
12:38but like I said, it's very addicting.
12:41So then after that, you know,
you start to think, okay, this
12:45mutation thing that I'm doing, these
optimistic updates, those are tedious.
12:50You know, it's like, well, I have to,
I have to make those perform, like make
12:54those optimizations myself and manipulate
the cache and it feels dirty, right?
12:59And so that's when it starts to get
a little more intense with like,
13:03okay, how could we make it so that
when I say I clicked this button.
13:10I should like this post somewhere that
I don't have to go in and manually
13:16kind of do the optimistic update that
my mutation can just know what it's
13:23going to affect, make the update, send
it to wherever it needs to go, and
13:29then it will sync when it needs to.
13:31And then we can just carry on, not
just as like a user interface to click
13:35something and be able to carry on
immediately, but also as a developer
13:39to be able to say, this is what's
changing, and then just move on.
13:43You know, not have to worry about
optimistic updates and cache
13:47and validations and whatnot.
13:48So this is where I think, at least for
me, where things start to get really,
13:54really fun and really, really scary.
13:56Mostly because it's just,
it's a new space, right?
14:01And, you know, to, give you my
perspective on it, I haven't gone
14:05too far down that rabbit hole to
be honest, because it involves a
14:10lot of knowledge about a system.
14:12usually involves knowing about schema
or, creating schema in some way.
14:18there's different implications for where
that data is being synced, whether it's
14:23local like offline or on a server or
through web sockets or REST or whatever.
14:28so there's just a lot that comes with
that and that has been intimidating
14:33for me because it's difficult for
me to generalize where like, React
14:37Query was easy to generalize.
14:39but it doesn't mean that
we're not thinking about it.
14:42You know?
14:43this was a, perfect tour from the
beginnings of the motivations that led
14:48to React Query and now TanStack Query,
the benefit it provides and like how
14:53far it gets you, but also like to the
point where it brings you where things
14:56are already working pretty well, but
maybe you face some new challenges
15:01and you would like things to work even
more automatically in the right way.
15:06You now need to better understand that.
15:09And this is also like nicely reflects,
like a lot of my thinking over the
15:13last decade where I've been wrestling
with the same ideas and the same
15:18challenges and a few points always like
bubbled up to me again as like those
15:24can't be ignored in a generalized way.
15:27And I think this is really the, key
point to underscore here, like looking
15:31for a generalized solution and like at
least I don't want to be the bearer of
15:35bad news, but I don't think for data
there is a generalizable solution because
15:40data is like the ultimate as it depends.
15:44And I think this is where a
technology like React as like
15:48the first of its kind in a way.
15:50showed us a, like close to generalizable
solution that applied so perfectly
15:57to so many different situations and
use cases, and unfortunately I don't
16:02think that is realistic for data.
16:04Just because for data you have
just different trade-offs.
16:08Let's say you're building a banking
app, this is where you really want to be
16:12certain has that wire gone out or not.
16:15But if you're building, let's say, a
note taking app, it is actually more
16:19important that you can just carry
on writing down your thoughts, then
16:24that you perfectly know that it's
also already arrived on the server.
16:29And so it's just different trade-offs
and those different trade-offs
16:33need or could be productized
and systematized into something.
16:38And this again, is where I think React
Query has been just so phenomenal in
16:44striking those trade-offs it meets
people, where most of them are, where
16:49they don't need the perfect thing.
16:51Something good is already
better than nothing.
16:54And then just like calling,
fetch themselves and then,
16:58dealing with that somehow.
17:00But for people who wanna now go
further for a more specialized path,
17:05I think this is where now there's like
a, tree of potential new approaches
17:10and potential new technologies.
17:11And some of them you've
been investigating.
17:14And I think, one particular like hairy
topic here to investigate further is
17:19like, how do you get for the writes
that you're doing for the optimistic
17:24updates or the updates more generally.
17:26What happens when you're updating
data, like most directly, you're
17:31updating data in like a local variable
somewhere, somehow running in your,
17:37let's say, React app, but then you're
also maybe posting to an API endpoint,
17:43and now it's already, the universes
are already potentially splitting.
17:48So you've updated your variable,
maybe your API request.
17:52Goes through.
17:53And as that API request is
being propagated further, fail
17:58somewhere there and now you
need to unwind the entire thing.
18:01But let's say maybe you do two
API requests, one goes through
18:04the other, doesn't go through.
18:06Now you're like in the
split brain situation.
18:09And so now you need to, should you wind it
back, should you partially wind it back?
18:14And now you need to handle that on your
API server as well as on your client.
18:19And on the client, maybe you just say
like, you know what, if we hit this
18:22case, it's so rare we just show an
error message and say the user like
18:26reload, but maybe it's not so rare.
18:28And then you need to think about
it in a more principled way.
18:32And this is where another kind
of manifestation of that is cash
18:36inconsistency and There is a
really great blog post, that goes
18:41along the lines of like, your
app shouldn't become a database.
18:45we'll link it in the description.
18:47But, I think that is like a very nice
and provocative post that shows the
18:52reality of most ambitious apps that
as you pull more on that thread, your
18:57app becomes a database with all the
hard things about a database, and it
19:03needs to be transactionally consistent.
19:05So if you click that button,
maybe it should reflect in
19:08instead over here and over there.
19:11And if it doesn't, your app feels
broken or things might actually like
19:15you get the dreaded, undefined is not
a function because like some, like
19:20array index is not there, et cetera.
19:23And the more you pull on that,
the more you want kind of like a
19:26React-like foundation that you can
just trust that is maybe a bit more
19:31specialized to your use case, but you
can actually trust and it just works.
19:36And this is where I hope things are going.
19:38Like, basically a tree of different
possibilities for, mature and well
19:43designed data systems that, match
the corresponding set of trade-offs.
19:49And it's now our role as educators to
educate developers which trade-offs
19:55work well for their apps and what are
good, solutions and systems for those.
20:01And I think that something like React
Query has been an excellent catch
20:06all that already lifts people up.