abhimuktheeswarar / flywheel Goto Github PK
View Code? Open in Web Editor NEWA simple and predictable state management library inspired by Redux for Kotlin Multiplatform using the concepts of actors.
License: Apache License 2.0
A simple and predictable state management library inspired by Redux for Kotlin Multiplatform using the concepts of actors.
License: Apache License 2.0
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.
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
State
and corresponding Actions
in shared
(my state has a boolean value modified by the actions)SDK
kotlin class where I have put a Reducer
and a StateReserve
Now on Swift side :
CoroutinesHelper.swift
filefinal 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
}
}
..
}
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 !)
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.