cycle-fire
A Firebase driver for Cycle.js.
Example
;;;; { const action$ = sourcesDOM ; const vdom$ = sourcesfirebasedatabase value; return DOM: vdom$ firebase: action$ ;} ;
API
firebaseActions
Write effects to the connected Firebase database are requested by calling an action generator—a function defined on the firebaseActions
object—and passed to the firebase
sink.
firebaseActions: object
containing:auth: object
containing:-
applyActionCode(code: string)
– triggersAuth.applyActionCode
-
checkActionCode(code: string)
– triggersAuth.checkActionCode
-
confirmPasswordReset(code: string, newPassword: string)
– triggersAuth.confirmPasswordReset
-
createUserWithEmailAndPassword(email: string, password: string)
– triggersAuth.createUserWithEmailAndPassword
-
sendPasswordResetEmail(email: string)
– triggersAuth.sendPasswordResetEmail
-
setPersistence(persistence: firebase.auth.Auth.Persistence)
– triggersAuth.setPersistence
-
signInAndRetrieveDataWithCredential(credential: firebase.auth.AuthCredential)
– triggersAuth.signInAndRetrieveDataUsingCredential
-
signInAnonymously()
– triggersAuth.signInAnonymously
-
signInWithCredential(credential: firebase.auth.AuthCredential)
– triggersAuth.signInWithCredential
-
signInWithCustomToken(token: string)
– triggersAuth.signInWithCustomToken
-
signInWithEmailAndPassword(email: string, password: string)
– triggersAuth.signInWithEmailAndPassword
-
signInWithPhoneNumber(phoneNumber: string, verifier: firebase.auth.ApplicationVerifier)
– triggersAuth.signInWithPhoneNumber
-
signInWithPopup(provider: firebase.auth.AuthProvider)
– triggersAuth.signInWithPopup
-
signInWithRedirect(provider: firebase.auth.AuthProvider)
– triggersAuth.signInWithRedirect
-
signOut()
– triggersAuth.signOut
user(user: firebase.User): object
containing:unlink()
– triggersUser.unlink
updateEmail(email: string)
– triggersUser.updateEmail
updatePassword(password: string)
– triggersUser.updatePassword
updatePhoneNumber(phoneNumber: string)
– triggersUser.updatePhoneNumber
updateProfile(profile: { displayName: (null|string), photoURL: (null|string) })
– triggersUser.updateProfile
-
verifyPasswordResetCode(code: string)
– triggersAuth.verifyPasswordResetCode
-
database: object
containing:-
goOffline()
– triggersDatabase.goOffline
-
goOnline()
– triggersDatabase.goOnline
ref(path: string) => object
containing:-
push(value: any)
– triggersReference.push
-
remove()
– triggersReference.remove
-
set(value: any)
– triggersReference.set
-
setPriority(priority: (null|number|string))
– triggersReference.setPriority
-
setWithPriority(value: any, priority: (null|number|string))
– triggersReference.setWithPriority
-
transaction(updateFn: (value: any) => any)
– triggersReference.transaction
-
update(values: any)
– triggersReference.update
-
-
<action>.as(category: string)
Effectively attaches a category
to the action's result stream, allowing for lookup using the source's select()
.
;; { const setAction = firebaseActionsdatabase ; sourcesfirebase; return firebase: xs ;}
makeFirebaseDriver(config, name?)
config: object
apiKey: string
authDomain: string
databaseURL: string
messagingSenderId: string
projectId: string
storageBucket: string
name?: string
Initializes a connection to a Firebase database by calling firebase.initializeApp()
, returning a source object containing the following:
auth: object
containing:-
authState: MemoryStream
emitting values fromAuth.onAuthStateChanged
-
currentUser: MemoryStream
emitting changed values ofAuth.currentUser
when triggered byAuth.onIdTokenChanged
-
idToken: MemoryStream
emitting values fromAuth.onIdTokenChanged
-
providersForEmail(email: string): MemoryStream
emitting values fromAuth.fetchProvidersForEmail
-
redirectResult: MemoryStream
emitting values fromAuth.getRedirectResult
-
database: object
containing:-
ref(path: string): ReferenceSource
containing:-
child(path: string): ReferenceSource
-
events(eventType: string): MemoryStream
of theref
'seventType
events, usingReference.on
-
value: MemoryStream
– a shortcut stream equivalent toevents('value')
-
-
refFromURL(url: string): ReferenceSource
-
-
select(category: string): Stream
of results from action requests that were categorized using<action>.as()
.