GithubHelp home page GithubHelp logo

vshkl / news-hacks Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 433 KB

Silly simple Hacker News RSS feed client made with Compose Multiplatform (Android, iOS, desktop)

License: MIT License

Kotlin 96.03% Swift 3.97%
compose-multiplatform detekt kotlin ktor sqldelight xmlunit

news-hacks's Introduction

News Hacks

A trivial playground app that uses Compose Multiplatofm to fetch RSS feed on the newest posts on Hacker News via Hacker New RSS.

Stack

  • Compose Multiplatform
  • Ktor
  • SqlDelight
  • KotlinX Serialization
  • Xmlutil
  • Detekt

Problems

XML parsing

There is no Kotlinx Seriaization implementation that works with XML for all targets – onlt for JVM, therefore it's needed to write a custom XMLConverted and register it inside Content Negotiation plugin for Ktor.

RFC 822 date

Kotlix Datetime library does not have suport for RFC 822 dates out of the box. Potentially, it is possible to implement some soft of rfc822toISO8601 function that is marked as expect in the common module and hasve actual implementations in all targets and use KotlinX Datetime library from that point onwards. I imagine this coversion should happen at the very "edge" of the app, at API level.

Depencency injection

Awkward. I tried Kodein and failed miserably while trying to provide a SQL drivers for each target. The main caveat was that for Android I need Context, and there was no straightforward way to provide one implementation with additional parameter. I mean, there are options, but they look funny. Koin is fine, though, but after all the fun with Kodein I decided to just povide "modules" manually:

There is a platform module where everything platform specific will go:

expect class PlatformModule {

    val sqlDriver: SqlDriver
}

and a common module that is self-explanatory:

class CommonModule {

    val httpClient: HttpClient = ...
}

This is by no means a scalable solution, but for the same of this app – it was just fine. Potentially, it is possible to use CompositionLocal to make it look a bit less ugly, though I'm still not shure thether or now it is a good idea.

About Compose Multiplatform

This is a Kotlin Multiplatform project targeting Android, iOS, Desktop.

  • /composeApp is for code that will be shared across your Compose Multiplatform applications. It contains several subfolders:

    • commonMain is for code that’s common for all targets.
    • Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name. For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app, iosMain would be the right folder for such calls.
  • /iosApp contains iOS applications. Even if you’re sharing your UI with Compose Multiplatform, you need this entry point for your iOS app. This is also where you should add SwiftUI code for your project.

Learn more about Kotlin Multiplatform

MIT Licence

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.