-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a wrapper to convert Settings
to ObservableSettings
by manually invoking callbacks
#155
Comments
This would certainly be useful. I’ve created a simpler version of this and would be happy to contribute if you decide to include it in the pipeline. |
I don't want to think too much about this until after getting 1.1 out the door, but would certainly welcome contributions. Is the version you've used available publicly anywhere? |
It is not available publicly yet. I'm working on a simple multiplatform app that will eventually be public. |
I finally published my app and here is the link to my implementation. Besides this, I also ended up adding some extensions to support stateflow. I can contribute these back if you think it adds some value to this project. |
Hi @psuzn, Sorry it's taken me a while to get back on this. I'd like to add something like this, and would welcome the contribution if you'd like to make a PR with your implementation. Some notes:
|
@psuzn Hey there! Are you by any chance about to create the aforementioned PR? Don't want to stress, though. |
Hey, @ChristianKatzmann I started to work on it a while ago, but something came up and I forgot. Will continue with it over the weekends and hopefully will push something soon. |
Since #184 has been merged, let's also close this. |
Will close once I get it released (which I'm admittedly way late on) |
makes sense, what are other things in the pipeline if there is anything I can help with? |
This is now released in 1.2 |
It would be pretty straightforward to create a class that manually wires in update listeners in Kotlin for platforms that don't natively have them.
The reason I've never added this to the library previously is, the interop story can get confusing here. For example, if you have platform code in JS interacting with
localStorage
directly, then making changes there would not trigger your listeners. Indeed even if you had multipleSettings
instances reading from the same storage, they wouldn't trigger each other's listeners in the implementation above.As KMP matures, there's a growing number of users for whom the interop story is less important than having an API that does everything they need in common code. So I'm reconsidering adding an API like this, and want to hear what others in the community think about it.
Some details I'm considering
multiplatform-settings-no-arg
, this would probably live in its own module. This way, you must explicitly opt into using it and are more likely to be aware of potential pitfalls. (An opt-in annotation might also help with this)ObservableSettingsWrapper
?ObservableSettingsWrapper(delegate)
or to use an extension api likedelegate.makeObservable()
? (This can help sidestep the class naming problem but the function still needs a name)ObservableSettings
, or should it always behave the same and it's up to the consumer to know when to use it?The text was updated successfully, but these errors were encountered: