Created
January 4, 2022 17:01
-
-
Save pocmo/d4c0d285b68cb0d14ae6ae162e55f608 to your computer and use it in GitHub Desktop.
Generic middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface StateWithTopSites : State { | |
val topsites: List<TopSite> | |
} | |
interface TopSite { | |
// .. | |
} | |
interface AddTopSiteAction { | |
val topSite: TopSite | |
} | |
class TopSitesMiddleware<S : StateWithTopSites, A : Action> : Middleware<S, A> { | |
override fun invoke( | |
context: MiddlewareContext<S, A>, | |
next: (A) -> Unit, | |
action: A | |
) { | |
when (action) { | |
is AddTopSiteAction -> TODO("Add to storage") | |
} | |
next(action) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment