Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/avohq/bs-firebase
https://github.com/avohq/bs-firebase
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/avohq/bs-firebase
- Owner: avohq
- License: mit
- Archived: true
- Created: 2017-10-25T23:26:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-19T18:46:05.000Z (about 5 years ago)
- Last Synced: 2024-11-09T17:06:56.294Z (2 months ago)
- Language: OCaml
- Size: 23.4 KB
- Stars: 42
- Watchers: 7
- Forks: 15
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-firebase - BuckleScript Bindings for Firebase - ReasonML 프로젝트에서 사용하기위한 Firebase 용 BuckleScript 바인딩 라이브러리입니다. (웹)
README
# BuckleScript bindings for firebase
Add type for in reason to google's firebase api documented
[here](https://firebase.google.com/docs/reference/js/).
## Install
yarn add (git url)
add to your bsconfig.json
```json
"bs-dependencies": [
...
"bs-firebase"
],
```## Example
```ocaml
let options =
{
"apiKey": "...",
"authDomain": "...",
"databaseURL": "...",
"storageBucket": "...",
"messagingSenderId": "..."
};let app = BsFirebase.ReasonFirebase.initializeApp(options);
let db = BsFirebase.ReasonFirebase.App.database(app);
BsFirebase.ReasonFirebase.Database.Reference.once(
BsFirebase.ReasonFirebase.Database.ref(db, ~path="ticket", ()),
~eventType="value",
()
)
|> Js.Promise.then_(
(teamDomain) => BsFirebase.ReasonFirebase.Database.DataSnapshot.val_(teamDomain)
|> (ticket) => parseTicket(ticket)
|> (ticketJson) => Js.log(ticketJson) //here you got a record of ticket type
|> Js.Promise.resolve
);type ticket = {
id: int,
name: string
};type state = {
ticket : ticket
};let parseTicket = (json): ticket =>
Json.Decode.{ //Json.Decode is from module https://github.com/reasonml-community/bs-json
id: json |> field("id",int),
name: json |> field("name", string)
};
```