Git Product home page Git Product logo

abhimuktheeswarar / flywheel Goto Github PK

View Code? Open in Web Editor NEW
41.0 1.0 3.0 48.66 MB

A simple and predictable state management library inspired by Redux for Kotlin Multiplatform using the concepts of actors.

License: Apache License 2.0

Kotlin 25.31% Swift 1.12% Ruby 0.14% Objective-C 73.43%
kotlin kotlin-multiplatform flux unidirectional-data-flow redux state-management flux-architecture elm-architecture redux-store redux-actions mvi android mvi-architecture mvi-android coroutines concurrency

flywheel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flywheel's Issues

Could not cast value of type '' to 'SharedKotlinx_coroutines_coreFlowCollector'

Hi,

I am trying to implement a very simple State in my KMM project and I run into an exception.
I don't know if I am doing things correctly, here are some details.

versions

  • kotlin : 1.5.30
  • flywheel : 1.1.4-RC
  • kotlinxCoroutines : 1.5.2-native-mt

use case

I would like to State defined in the shared kotlin code base and I would like to collect this State in my Swift view model.

On Kotlin side

  • I made an State and corresponding Actions in shared (my state has a boolean value modified by the actions)
  • I have SDK kotlin class where I have put a Reducer and a StateReserve

Now on Swift side :

  • I have imported flywheel framework and the CoroutinesHelper.swift file
  • I have defined the following state in a ViewModel :
final class MyViewModel: ObservableObject {
    let sdk: MySDK

    @Published var myState: MyState = MyState(myBoolean = false)

    init() {
        sdk = MySDK()
        sdk.myStateReserve.states.collect(collector: Collector<MyState> { myState in
            self.myState = myState
        } as! Kotlinx_coroutines_coreFlowCollector) { (unit, error) in
            // code executed if the Flow object is completed
        }
    }

    ..
}

what is happening

So the first thing different from the sample code you provided is that I am forced to cast Collector<MyState> to Kotlinx_coroutines_coreFlowCollector

And surely the problem is here as the Exception is the following, calling init():

Could not cast value of type '_TtGC6iosApp9CollectorCSo18SharedMyState_' (0x11046c4d0) to 'SharedKotlinx_coroutines_coreFlowCollector' (0x10218ae48).

Am I doing the most simple thing to collect a state in Swift ? If not I am interested to know how I can improve my code !
Thank you so much !

(BTW wiki documentation is great !)

How would you unit test Actions/Side Effects

Love the library! Great work. I really like the structure and design of it. I am, however, struggling to write unite tests for some code I wrote using this library. Most likely it's just a lack of understanding on my part, but I seem to keep running into deadlock issues when running tests. I'm using the new coroutine test library for testing common code. How would you go about testing SideEffects or Actions in this library?

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.