[HN Gopher] TinyBase v2.0: reactive data store for local-first apps
       ___________________________________________________________________
        
       TinyBase v2.0: reactive data store for local-first apps
        
       Author : jamesgpearce
       Score  : 51 points
       Date   : 2022-09-16 20:08 UTC (2 hours ago)
        
 (HTM) web link (tinybase.org)
 (TXT) w3m dump (tinybase.org)
        
       | pbronez wrote:
       | Nice work. I love anything that makes local-first easier. I've
       | been paying close attention to Dolt for this. In a perfect world
       | I'd have the gut semantics from Dolt and EdgeQL from EdgeDB.
       | 
       | This focuses on the reactive feature - the ability to set
       | listeners and get alerts. There seem to be some nice React
       | integration, but haven't built with React enough to immediately
       | see what that unlocks.
        
         | jamesgpearce wrote:
         | Thank you. I figured that getting/setting/listening are the key
         | primitives, and then the React layer (which is just one of many
         | theoretical UI library bindings) can use hooks and components,
         | or whatever, to simply wrap them. I'm not familiar with Dolt,
         | but seems like I need to become so!
        
       | jamesgpearce wrote:
       | Author here, if anyone has any thoughts or feedback. Bring it on!
        
         | pbronez wrote:
         | Congratulations on shipping!
         | 
         | Can you explain your motive for focusing on the combination of
         | reactive data and local deployment?
         | 
         | My first thought is that local-first = one user = I know what's
         | changing because I'm the only one using it. Perhaps valuable
         | for monitoring external data feeds?
        
           | jamesgpearce wrote:
           | Yeah, I see your point. I've been assuming that local-first
           | doesn't mean local-only. Even if it's just you, you could
           | easily be polling something else to get data updates, as you
           | suggest. (One original use case was a personal GitHub
           | dashboard app that polled for new activity but provided local
           | analytics).
           | 
           | A couple of great essays I've enjoyed in this space are
           | https://www.inkandswitch.com/local-first &
           | https://riffle.systems/essays/prelude/
           | 
           | I feel it should be possible to build certain types of apps
           | that can view, query, and manipulate denormalized data
           | without even being online. (Perhaps I shouldn't over-
           | glamorize those days when one used to jam Access databases
           | into Windows apps, but hopefully you get the point.)
           | Reactivity just serves as a nice binding paradigm.
        
         | mfbx9da4 wrote:
         | Wait so can you actually connect tiny base to SQLite?
        
           | jamesgpearce wrote:
           | No, there's no _actual_ RDBMS involved. The query engine uses
           | a functional style of query that has similar concepts to SQL,
           | but all the evaluation (and reactivity) is first party, in
           | the library itself.
           | 
           | Of course it would be pretty easy/fun to persist your
           | TinyBase content into a SQLite database, or pull a dataset
           | from it. The demos load up TSV but you could easily do
           | something similar from an actual database somewhere.
        
             | mfbx9da4 wrote:
             | If I understand correctly the issue with storing and
             | retrieving from SQLite is that it won't be incremental?
        
               | jamesgpearce wrote:
               | It could be made to be. The current persistence
               | implementations are all batch but I believe they could be
               | row, or even cell-level, theoretically. Nice idea.
        
         | fillest wrote:
         | The font is unreadable, very thin
        
           | julienreszka wrote:
           | I agree.
        
           | jamesgpearce wrote:
           | Ouch, tough crowd, but fair enough!
           | 
           | I wonder if I should have a font-weight (or -family) toggle
           | alongside the dark mode setting. Would be a shame for people
           | to miss out on reading about the software because of the
           | typography!
        
           | j-bos wrote:
           | I like the thin font on mobile.
        
             | fillest wrote:
             | On mobile it is indeed at least not blurry but still harder
             | to read..
        
           | jzcoder wrote:
           | I immediately close a page dense in text and using a thin
           | font like Lato or Raleway.
        
             | modzu wrote:
             | im never happy no matter what i do
        
         | mfbx9da4 wrote:
         | The main limitation I see with tiny base is that it has to load
         | all data in one batch and modifying any record results in the
         | whole data store being persisted to disk. Surely this can't
         | scale well...
        
           | jamesgpearce wrote:
           | The data is in memory, and the persistence strategy is kind
           | of up to you. So it would scale reasonably if you put the
           | sync/persist on a different schedule to the UI - perhaps when
           | the browser is idle.
           | 
           | BUT of course, this is not a library to be used with data
           | sets of billions of rows! I'd recommend a proper RDBMS for
           | that ;)
        
             | mfbx9da4 wrote:
             | Yeah but I feel like it could be used for that, if only
             | retrieval and storage could be done incrementally...
        
               | mfbx9da4 wrote:
               | You're 80% of the way there now that you have encoded SQL
               | lite syntax now all you have to do is to translate that
               | into raw SQL queries to be executed
        
               | jamesgpearce wrote:
               | Correct. I think this could be done, but I would need to
               | think a little about how best to. Thank you for the idea!
        
         | 1egg0myegg0 wrote:
         | Howdy! What are the rough edges when persisting to a server?
         | What are the gaps relative to something like PouchDB?
        
           | jamesgpearce wrote:
           | Honestly, just my personal confidence currently. There's very
           | basic locking and store-wide read-write. I really aspire to
           | some sort of CRDT implementation that can be considered a bit
           | more state-of-the-art and tolerant to the innumerable
           | challenges of that problem.
        
       | pinum wrote:
       | I looked into building something like this for a React Native
       | app. (Actually I first considered the practicality of making a
       | reactive version of sqlite... I decided it would be too complex
       | and not something I'd want to use without upstream support).
       | 
       | We ended up doing something a bit more traditional/basic/manual,
       | but this looks nice. It would definitely have been in
       | consideration if it'd been available at the time, and I'll keep
       | it in mind for future projects.
        
         | jamesgpearce wrote:
         | Cool! Please take a look and see if it works out. I should
         | point out that the ui-react library (that provides React
         | bindings) does _not_ depend on ReactDOM, so you can use it just
         | as easily in React Native.
         | 
         | At least, once I got the bundler to be happy about the export
         | format! Please see
         | https://github.com/tinyplex/tinybase/issues/17#issuecomment-...
        
       | [deleted]
        
       | thruflo wrote:
       | Looks great, congrats on shipping :)
        
         | jamesgpearce wrote:
         | thanks! - it's been a labor of love :)
        
       ___________________________________________________________________
       (page generated 2022-09-16 23:00 UTC)