Listening to real-time changes on the database with Flutter and Supabase

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
with flutter and Supabase it's easy to  create real-time apps that reacts to the   changes happening on your database hi there  in this video we're going to take a look at   the real-time feature that supervised offers and  how we can use them in our flutter applications   currently Supabase offers three  different types of real-time   features postgis changes which is used to  listen to your changes on your database   presence which is used to listen to who  is present on your app and broadcast   which is used to share lowland AC real-time data  between clients without bypassing your databases   we're going to take a look at the postgres changes  and lead the other two for another time let's Dive   In by default the real-time feature is disabled  for all tables and you can enable real-time on a   per table basis from your supervised dashboard go  to database replication supervised real time and   select the table you want real time to be turned  on the Supabase flutter Library provides two ways   to listen to real-time post-gas changes stream and  unsubscribe both can be used to listen to changes   happening on your tables the difference between  the two is that stream provides the initial data   as well as the ongoing changes on the database  whereas unsubscribe only fires callbacks for   events that happen after establishing a connection  if you want to for example display a list of tab   messages using stream will be easier constructing  a stream is easy you just call from and pass a   table you want to listen to and call stream on it  you have to pass the list of primary key Columns   of the table which a lot of times is just ID the  resulting stream will return you a list of map of   string Dynamic upon listening to it you can also  apply a filter to narrow down your results is that   the time of this recording supported filters  include the following but check out our docs   for the latest list you can also add order and  limit Clause to further optimize the data you want   to receive a typical stream query for listening  to messages in a chat room could look something   like this just pass this to the stream Builder  and you have a UI for the list of messages now   moving on to unsubscribe unsubscribe is actually  what is being used by the stream method under the   hood and is a lower level way to access super  bass's real-time feature the way you construct   a unsubscribed callback is to call channel on and  pass postgres changes is a type channel here can   be anything as long as it's Unique or Costco app  now channel filters where we specify more details   about what changes we want to listen to event  specifies what event you want to listen to and can   be all insert update or delete schema specifies  the schema of the table you want to listen to   and typically should be public table is the table  you want to listen to you can also omit the table   parameter to listen to changes happening in all  real-time enabled tables filters where you pass   filters to further narrow down the events you  want to listen to the same sets of filters are   available as the stream method within the Callback  the payload will contain new and old map of the   changed row a good use case of using unsubscribe  would be when you want to show a dialogue or snack   bar reacting to changes in a database you might  want to for example show a snack bar within your   app when a new message was inserted while your  user had the app opened and that is how you   can use super bass real-time with flutter see you  next time in another video of flutter and Supabase
Info
Channel: Supabase
Views: 6,495
Rating: undefined out of 5
Keywords:
Id: gboTC2lcgzw
Channel Id: undefined
Length: 3min 31sec (211 seconds)
Published: Thu May 18 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.