GithubHelp home page GithubHelp logo

anirudhpudari / kotlinflows Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

Kotlin flows

Home Page: https://medium.com/@auroraanirudh/kotlin-flows-973002e28d73

License: MIT License

Kotlin 100.00%
kotlin kotlin-android kotlinandroid kotlinflows kotlin-examples kotlin-lang kotlin-native kotlintutorial

kotlinflows's Introduction

KotlinFlows

Summary

This repository is a collection of code examples on my understanding of kotlin flows. It includes ways to construct flows using flow builders,some intermediate and terminal operators and also exception handling.

Contents

  • How are Flows Constructed?
  • Intermediate Operators
  • Terminal Operators
  • Exceptions

Flow Operators covered

  • flow{...}
  • asFlow()
  • flowOf()
  • map()
  • filter()
  • take
  • zip
  • collect()
  • toList()
  • toSet()
  • single()
  • reduce()
  • fold()

Find this repository useful? ❤️

  • Support it by starring this repository. ⭐

  • And follow me on Medium

Pre-requisites

  • Experience with Kotlin syntax.
  • How to create and run a project in IntelliJ IDEA.

Getting Started

  • Install IntelliJ IDEA Studio, if you don't already have it.
  • Download the sample.
  • Import the sample into IntelliJ IDEA Studio.
  • Build and run the sample.

kotlinflows's People

Contributors

anirudhpudari avatar

Watchers

 avatar

kotlinflows's Issues

Include Missing Terminal operators

  • Include these missing Terminal operators in the code
  1. count - counts the number of emitted values
  2. first - returns the first emitted value
  3. last - returns the last emitted value
  4. firstOrNull - returns the first emitted value, or null if there are no values
  5. lastOrNull - returns the last emitted value, or null if there are no values
  6. singleOrNull - returns the only emitted value, or null if there are multiple or no values.

Include missing Intermediate Operators

  • Include these missing Intermediate operators
  1. takeWhile - takes values from the flow until a specified condition is no longer met, and then cancels the flow
  2. drop - drops the first n emitted values and emits the rest
  3. dropWhile - drops values from the flow until a specified condition is no longer met, and emits the rest
  4. distinctUntilChanged - filters out emitted values that are equal to the previous value
  5. flatMapConcat - applies a transformation that returns a new Flow for each emitted value, and concatenates them into a single Flow
  6. flatMapMerge - applies a transformation that returns a new Flow for each emitted value, and merges them into a single Flow
  7. onEach - applies a side effect to each emitted value without modifying it
  8. buffer - buffers emitted values and emits them in batches
  9. debounce - waits for a specified time after each emitted value and emits only the latest value in that time period.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.