molecule icon indicating copy to clipboard operation
molecule copied to clipboard

More samples

Open JakeWharton opened this issue 2 years ago • 7 comments

If the recent Coding with the Italians podcast has taught me anything it's that we need more samples which showcase the usage outside of the traditional Android usage.

  • [ ] Ktor server sending state over a web socket
  • [ ] Test of regular Compose UI logic (Android and JVM desktop)
  • [ ] Data layer stuff? We show a lot of presentation layer but this can be used anywhere.
  • [ ] Cheap version of Mosaic rendering strings for terminal using K/N

JakeWharton avatar Nov 26 '23 05:11 JakeWharton

For reference: https://www.youtube.com/watch?v=O70beCWbSCY

oldergod avatar Nov 27 '23 09:11 oldergod

  • [ ] rememberSaveable plumbing

JakeWharton avatar Nov 29 '23 03:11 JakeWharton

@JakeWharton on the data layer side of things: do you have a vision for how you think it should look? I've been thinking about this exact concept quite a bit. Happy to contribute if it'd be helpful, let me know if you've got initial thoughts and I'll build something out.

morrisseyai avatar Nov 29 '23 04:11 morrisseyai

No ideas. Maybe maintaining pagination state of some remote API?

JakeWharton avatar Nov 29 '23 04:11 JakeWharton

One thing I'd like a sample on (if it's supported) is whether or not you can nest molecule flows. E.g. a Composeable in a Molecule scope calls "collectAsState()" on another flow that is also a molecule flow. It's not clear to me whether or not that's an anti-pattern based on the docs.

jmalpasuto avatar Feb 28 '25 19:02 jmalpasuto

Nothing should prevent that from working, but I wouldn't encourage it too much. That can be useful if you're going through some abstraction layer that only supports flows or you need to apply some operator first (like sharing/replay), but otherwise you could make the @Composable function driving the flow directly available to the one collecting the flow and do a direct call for the same result.

JakeWharton avatar Feb 28 '25 20:02 JakeWharton

@JakeWharton That makes sense, thanks! This is basically for a case where I might have an arbitrary molecule flow in my data layer for the sole reason that it's simply easier to to use Compose than a bunch of Flow operators to achieve what I'm trying to do. But it's good to know this isn't necessarily recommended.

jmalpasuto avatar Mar 07 '25 19:03 jmalpasuto