Skip to content

Commit

Permalink
chore: reactfire bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
czabaj committed Aug 15, 2023
1 parent 28de45e commit 8e3aca4
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/backend/Reactfire.res
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ type observableStatus<'a> = {
status: @string [#error | #loading | #success],
}

type reactfireOptions<'a> = {
// force usage of fieldId
idField: @string [#uid],
initialData?: 'a,
suspense?: bool,
}

@module("reactfire")
external useAnalytics: unit => Analytics.t = "useAnalytics"

Expand All @@ -51,19 +58,24 @@ external useFirestoreDocData: (
@as(json`{ "idField": "uid" }`) _,
) => observableStatus<'a> = "useFirestoreDocData"

type reactfireOptions<'a> = {
// force usage of fieldId
idField: @string [#uid],
initialData?: 'a,
suspense?: bool,
}

@module("reactfire")
external useFirestoreDocDataWithOptions: (
documentReference<'a>,
~options: option<reactfireOptions<'a>>,
) => observableStatus<'a> = "useFirestoreDocData"

@module("reactfire")
external useFirestoreDocDataOnce: (
documentReference<'a>,
@as(json`{ "idField": "uid" }`) _,
) => observableStatus<'a> = "useFirestoreDocDataOnce"

@module("reactfire")
external useFirestoreDocDataOnceWithOptions: (
documentReference<'a>,
~options: option<reactfireOptions<'a>>,
) => observableStatus<'a> = "useFirestoreDocDataOnce"

@module("reactfire")
external useFirestoreCollectionData: (
query<'a>,
Expand Down

0 comments on commit 8e3aca4

Please sign in to comment.