Giter Club home page Giter Club logo

trikot.streams's Introduction

⚠️ Warning: this project as been moved

See the new trikot repository for releases starting from 3.0.0.

Trikot.streams

Elegant implementation of ReactiveStreams for Kotlin Multiplatform.

  • Manage object immutability in native implementation (Object are frozen when switching threads)
  • Multithread support with ObserveOn and SubscribeOn processors
  • Simplify the management of publishers subscriptions and unsubscriptions
  • Help you focus on what you need to do by hiding Multiplatform complexity

Sample

Common code

class SearchController() {
    private val searchKeywordPublisher = Publishers.behaviorSubject<String>("keyword")
    private val searchResultsPublisher = searchKeywordPublisher.switchMap { keyword ->
        searchService.search(keyword)
    }.shared()
    val searchResultCount = searchResultsPublisher.switchMap { results ->
        PublisherFactory.create(results.count).toString()
    }
    val resultUppercaseTitles = searchResultsPublisher.map { it.title.toUpperCase() }
    val searchResultCountLabel = searchResultsPublisher.map { "${it.results.count()} results" }
    fun searchFor(keyword: String) {
       searchKeywordPublisher.value = keyword 
    }
}

Swift

See swift extensions for more information.

Helps connect a publisher to a variable in a reactive environment.

let label = UILabel()
label.bind(searchController.searchResultCountLabel, \UILabel.text)

Android

See android-ktx for more information.

Binding helpers relies on AndroidViewModel and uses lifecycleOwner to manage subscription and unsubscription.

val searchResultLiveData = searchController.searchResultCountLabel.asLiveData()

Foundation of trikot.streams is based on a immutable and concurrent implementation of Reactive-Streams.

Subscription and unsubscription are managed trough Cancellable and CancellableManager.

Installation

Import dependencies
    maven { url('https://s3.amazonaws.com/mirego-maven/public') }

    api "com.mirego.trikot:streams:$trikot_streams_version"
    jvm "com.mirego.trikot:streams-jvm:$trikot_streams_version"
    js "com.mirego.trikot:streams-js:$trikot_streams_version"
    iosx64 "com.mirego.trikot:streams-iosx64:$trikot_streams_version"
    iosarm64 "com.mirego.trikot:streams-iosarm64:$trikot_streams_version"

License

Trikot.streams is © 2018-2019 Mirego and may be freely distributed under the New BSD license. See the LICENSE.md file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We’re a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.

trikot.streams's People

Contributors

mirego-builds avatar martingagnon avatar jdtremblay avatar npresseault avatar antoinelamy avatar hugolefrancois avatar marcantoinefortier avatar gbourassa avatar marclefrancois avatar madumo avatar jfcartkeep avatar gingman avatar charlesmcd avatar etiennestpierre avatar captaindaniel avatar frobert11 avatar boubalou avatar mathieularue avatar mathieulegault1 avatar remi avatar wjobin avatar

Stargazers

Jitty Andiyan avatar Takahiro Menju avatar beforeold avatar  avatar Felipe Costa avatar Matthew Lee avatar Jiaheng avatar Rajkumar Singh avatar  avatar Edward Xie avatar  avatar Anthony Jean avatar Ernest Bursa avatar Chris avatar Abass Bayo avatar  avatar  avatar  avatar Dayan Ruben avatar  avatar steven de Tilly avatar  avatar  avatar Daniele Campogiani avatar  avatar  avatar Alan Boudreault avatar Brandon Roberge avatar  avatar  avatar Aleksey Mikhailov avatar  avatar Samuel Cabral Cruz avatar

Watchers

 avatar James Cloos avatar  avatar Luc Bernard avatar Patrick Bonneau avatar Olivier Cartier avatar  avatar Mathieu Baron avatar  avatar  avatar  avatar Olivier Pineau avatar  avatar Pascal Turcot avatar Philippe Dupuis avatar Vincent Ribou avatar Guillaume Audet avatar  avatar Thomas Duplaix avatar steven de Tilly avatar Andréanne Guay avatar Marie-Pierre Tremblay avatar Philippe Lachance avatar  avatar Alexander Pawinski avatar  avatar Matthew Kevork avatar

Forkers

cybernetics

trikot.streams's Issues

Error on Swift extension setup

Hello! I'm trying to setup Streams and can't get Swift Extensions to work but I have an error. I did add all the dependencies in my shared library. Inside my Podfile I set TRIKOT_FRAMEWORK_NAME environment variable.

When I build my project, I get error inside TrikotPublisherExtensions as it can't find CancellableManager, Publisher... I checked the file and the correct import is there: import shared (the name of my share library.

When I check the pod's share.framework headers, Streams classes are exported as SharedStreams*** which this is why it can't resolves the name I mentioned above.

Anything that I'm missing ? Or should the extension be using those names instead?

Also, while checking swift extension the setup, there is a reference to Trikot.patron which doesn't exists. Just a little heads up 😄

Thanks!

Writing tests in kotlin

I think we should write our tests in kotlin instead of groovy with spock so that we can run them not only on the JVM but also on JS and Native.

There are a few librairies that allows us to do that and while mockk does not support native (mockk/mockk#58), it might eventually do and it will be easier to transition kotlin tests when they do.

However, there was a recent breakthrough that could make mockk usable on native with some extra function calls:
https://www.reddit.com/r/Kotlin/comments/bu1ri7/multiplatform_mocking_workaround/

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.