Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consider how firebase realtime database can be incorporated as a core feature #129

Open
gureckis opened this issue Apr 11, 2024 · 3 comments
Assignees

Comments

@gureckis
Copy link
Member

  • how does it work with the smilestore data store?
  • how would it be enabled in the smile API?
  • how would it be reflected in the UI for the developer mode tools?
@rhezab
Copy link

rhezab commented Apr 16, 2024

Ok I was initially treating this issue as "implement generalizable template code for multi-player games", but I'm realizing that's somewhat orthogonal to incorporating firebase rtdb as a core feature. So I'll make a separate issue addressing that separately (#139).

With respect to how rtdb can be incorporated as a core feature, I think that the first step would be to incorporate it with smilestore (and then the smile API can act like a wrapper). My rough plan is to:

  • add an action called useRTDB that sets everything up to use RTDB, storing refs to rtdb and such in local storage. might be easier if this function is written in firestore-db.js and imported in smiledata.js
  • add actions for setting/removing/reading/listening/etc with RTDB, so that there's no need to import RTDB stuff for each component separately
  • consider adding an object (like smilestore.data or smilestore.local) that syncs with RTDB, but not sure if this is a good idea because it might just make things more complicated (you need to say which parts of RTDB you want to sync with, since you don't want to sync with irrelevant parts of the RTDB, etc.). maybe this is more something for the multi-player functionality, when it comes.

Wrt plan item 2, implement wrappers for the following:

import {
  set, // done
  get, // done 
  child, // done 
  ref as rtref, // done
  remove, // done 
  serverTimestamp,
  onDisconnect,
  onValue, // done 
  update, // done
  runTransaction,
  off
} from "firebase/database";

Particularly important are: set, get, rtref, remove, onValue, onDisconnect

@rhezab
Copy link

rhezab commented Apr 16, 2024

changelog:

  • firestore-db.js: added function getRTDB
  • smiledata.js
    • added rtdb and rtdb_path to smilestore.local, which are initialized to null
    • added action setRTDB which sets rtdb and rtdb_path
    • a bunch of wrappers for rtdb methods (see above), bookended by /* begin new*/ and /* end new */
  • smileapi.js
    • added smilestore to api object so can use api.smilestore

@rhezab
Copy link

rhezab commented Apr 16, 2024

Ok all but one wrapper implemented in smilestore, just need to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants