From 2aae8dc0e23bbdbba94ae5e6a293f2bc1b8dce64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hor=C3=A1cio=20Com=C3=A9?= Date: Sat, 5 Jun 2021 14:51:36 +0200 Subject: [PATCH 1/2] formatting --- README.md | 80 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 4de1acb..90920ff 100644 --- a/README.md +++ b/README.md @@ -1,66 +1,67 @@ # fireflow -[![](https://jitpack.io/v/horaciocome1/fireflow.svg)](https://jitpack.io/#horaciocome1/fireflow) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=19) +[![](https://jitpack.io/v/horaciocome1/fireflow.svg)](https://jitpack.io/#horaciocome1/fireflow) . [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=19) ## Getting Started -Android library that aims to hide Firebase Firestore listener implementation and expose only a Kotlin Flow of specified type. ;) +Android library that aims to hide Firebase Firestore listener implementation and expose only a Kotlin Flow of specified type. ;) Works for ColletionReferences, Queries, and DocumentReferences. ## Pre-requisites -Check the pre-requisites for Firebase Firestore and for Kotlin Flow on respective documentation. -Be familiar with Kotlin Coroutines. +Check the pre-requisites for Firebase Firestore and for Kotlin Flow on respective documentation. +Be familiar with Kotlin Coroutines. Based on versions **23.0.1** and **1.4.1** of _firebase-firestore-ktx_ and _kotlinx-coroutines-play-services_ respectively ## Adding to your project Lets start by adding a corresponding repository in your _root_ `build.gradle` file. ```gradle - allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } +allprojects { + repositories { + ... + maven { url 'https://jitpack.io' } } +} ``` The next task is to add the dependency to your _app_ `build.gradle` file. ```gradle - dependencies { - ... - implementation 'com.github.horaciocome1:fireflow:0.0.1' - } +dependencies { + ... + implementation 'com.github.horaciocome1:fireflow:0.0.1' +} ``` -Now you ready to go. You might want to _**sync your project**_ first. ;) +Now you ready to go. +You might want to _**sync your project**_ first. ;) ## How to use ### without fireflow ```kotlin - val db = FirebaseFirestore.getInstance() - val ref = db.collection("posts") - ref.addSnapshotListener { snapshot, error -> - if (error != null) { - // handle - } else if (snapshot != null) { - val posts = snapshot.toObjects(Post::class.java) - // set posts to UI - } +val db = FirebaseFirestore.getInstance() +val ref = db.collection("posts") +ref.addSnapshotListener { snapshot, error -> + if (error != null) { + // handle + } else if (snapshot != null) { + val posts = snapshot.toObjects(Post::class.java) + // set posts to UI } +} ``` ### with fireflow ```kotlin - val db = FirebaseFirestore.getInstance() - db.collection("posts").getAsFlow().collect { posts -> - // set posts to UI - } +val db = FirebaseFirestore.getInstance() +db.collection("posts").getAsFlow().collect { posts -> + // set posts to UI +} ``` You can also read documents as flows ```kotlin - val db = FirebaseFirestore.getInstance() - db.collection("posts").document("1") - .getAsFlow().collect { post -> - // set post to UI - } +val db = FirebaseFirestore.getInstance() +db.collection("posts").document("1") + .getAsFlow().collect { post -> + // set post to UI + } ``` ## Troubleshooting -There is no Java support. +There is no Java support. For other things please open an Issue or reach me via [hcome@pm.me](mailto:hcome@pm.me) ## Licenses @@ -78,14 +79,15 @@ For other things please open an Issue or reach me via [hcome@pm.me](mailto:hcome See the License for the specific language governing permissions and limitations under the License. ### Not maintained by us - Firebase Firestore is a product of Google. - Kotlin is a product of Jetbrains. + [Firebase Firestore](https://firebase.google.com/docs/firestore/) is a product from Google. + [Kotlin](https://kotlinlang.org/) is a product from Jetbrains. ## How to contribute We open to suggestions of any kind. Email me, open pull requests, etc. -## Less Boilerplate Utils -If you want to see another utility please check my work on Recyclerview. -[Simple RecyclerView Listener](https://github.com/horaciocome1/simple-recyclerview-listener) -[Simple RecyclerView Adapter](https://github.com/horaciocome1/simple-recyclerview-adapter) \ No newline at end of file +## More +Hope you development experience gets smootherrrrr. +If you want to see another utility please check my work on Recyclerview. +[Simple RecyclerView Listener](https://github.com/horaciocome1/simple-recyclerview-listener) +[Simple RecyclerView Adapter](https://github.com/horaciocome1/simple-recyclerview-adapter) From ae93450e44344e4599421a6209325c30d3407b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hor=C3=A1cio=20Com=C3=A9?= Date: Sat, 5 Jun 2021 14:54:34 +0200 Subject: [PATCH 2/2] typos --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 90920ff..42bf8e5 100644 --- a/README.md +++ b/README.md @@ -14,16 +14,16 @@ Based on versions **23.0.1** and **1.4.1** of _firebase-firestore-ktx_ and _kotl Lets start by adding a corresponding repository in your _root_ `build.gradle` file. ```gradle allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } + repositories { + .. + maven { url 'https://jitpack.io' } + } } ``` The next task is to add the dependency to your _app_ `build.gradle` file. ```gradle dependencies { - ... + .. implementation 'com.github.horaciocome1:fireflow:0.0.1' } ```