Support for popular frontend libraries #12
Replies: 5 comments 2 replies
-
Here are a few quick thoughts to kick off the discussion.
This may be a topic for another discussion, but am I right assuming that you want to keep the procedural programming style for this library? I'm not trying to convince you of something else. I just want to understand your considerations and implementation goals a little better. |
Beta Was this translation helpful? Give feedback.
-
I've since started work on the React client. You can view progress here. While iterating on ideas, I changed the retrieval of tables from the model to this: const model = (db) => ({
users: createTable<User>(db, "users")(),
nested: {
table: createTable<Post>(db, "posts")()
}
}) satisfies ValidModel;
type Model = ModelOf<typeof model>;
const Component = () => {
const userTable = useTable((model: Model) => model.users);
const postTable = useTable((model: Model) => model.nested.table);
...
} As far as I can tell, this provides no disadvantages compared to the string-based retrieval method as detailed above ( I may change it back before fully releasing the React client, I'm not too sold on the idea yet. |
Beta Was this translation helpful? Give feedback.
-
Current status: React library implemented, available under I'm currently adding the ability to switch between types of API references for the website. This allows users to view different reference pages depending on their needs. For example, the API for exports from In the future, this should make it easier to add docs for other frontend libraries (Svelte, Vue, ...) while still having a readable reference documentation. |
Beta Was this translation helpful? Give feedback.
-
I released the React package a few days ago! 🚀 See v0.13.0. Since the doc rewrite is done now, this should now be less work. |
Beta Was this translation helpful? Give feedback.
-
Starting work on the Vue plugin, which is gonna be my final frontend package before the v1.0.0 release. |
Beta Was this translation helpful? Give feedback.
-
BlinkDB is 100% frontend framework & library agnostic, and can be used with just about any other frontend technology you can imagine. Nevertheless, there are some features that could be benefitial to most frameworks. I'm planning to create auxiliary packages for React, Vue, Svelte & Solid that wrap most methods in a way more accessible to their respective frontend library.
💡 If you want to support BlinkDB with some code, now would be the perfect opportunity to integrate BlinkDB into your favourite frontend framework :D
In this discussion, I'm going to lay out the plans for the frontend integration for React which I'm going to implement in the near future, but most of the following points apply to every framework that has some idea of hooks/contexts/etc. If you're planning on writing your own package, of course you're not required to follow everything here to the letter, since every framework has its ins and outs which all require different code structures.
The auxiliary package for React will be named
@blinkdb/react
, and will haveblinkdb
as a peer dependency.The general aim of the package is to provide hooks for all database retrieval methods, and to create a context provider for DBs & tables.
Context providers
For React,
createDB()
andcreateTable()
should have their own context.Tables should be retrievable by context using a custom
useTable()
hook (which just wrapsuseContext
):Hooks for database retrieval
In React, a component that needs to fetch data using "vanilla" BlinkDB might look like this:
This logic should be factored out into a custom hook
useMany
hook that accepts a table & a query and returns the retrieved items:It will also be benefitial to return properties like
isLoading
orerror
similar to other data fetching libraries like https://tanstack.com/query/latest or https://swr.vercel.app/.Next to the
useMany()
hook, auseFirst()
,useOne()
anduseCount()
hook will also be required.Database-modifying methods
BlinkDB methods that modify the database in some way (
insert()
,upsert(),
,updateWhere()
, etc.) need not be wrapped by the@blinkdb/react
package. These methods will most commonly only be used in event handlers anyway.Have any objections, better/more performant designs, or ideas for implementations other frontend frameworks? Leave a reply! I'll periodically update this post with information while I'm working on the React package.
Beta Was this translation helpful? Give feedback.
All reactions