Skip to content

Instantly share code, notes, and snippets.

View patjackson52's full-sized avatar

Patrick Jackson patjackson52

View GitHub Profile
@patjackson52
patjackson52 / SynchronizedStore.kt
Created April 7, 2020 19:05
A threadsafe wrapper of ReduxKotlin store. Multiplatform compatible.
/**
* Threadsafe wrapper for ReduxKotlin store that synchronizes access to each function using
* kotlinx.AtomicFu [https://github.com/Kotlin/kotlinx.atomicfu]
* Allows all store functions to be accessed from any thread.
* This does have a performance impact for JVM/Native.
* For use with [https://ReduxKotlin.org]
*/
class SynchronizedStore<TState>(val store: Store<TState>) : Store<TState>, SynchronizedObject() {
override var dispatch: Dispatcher = { action ->
@patjackson52
patjackson52 / ProfilingStore.kt
Created April 7, 2020 17:07
ProfileingStore - provides a wrapper around a ReduxKotlin store that profiles all calls to function. For testing purposes only, do not use in production.
/**
* Wraps all calls to Redux store with a profile function that reports the
* milliseconds to complete operation. getCurrentSystemTime & logger are passed as params
* so can work in multiplatform (provide your own implementation)
*
* @param store Redux store from [https://ReduxKotlin.org]
* @param getCurrentSystemTime function that returns current sys time in ms
* @param logger function that logs
*/
class ProfilingStore<T>(
@patjackson52
patjackson52 / polymorphic_json.json
Created March 6, 2019 18:15
Polymorphic JSON parsing with Kotlinx Serialization
val response: MyFoodWrapper = client.get {
apiUrl("url_to_polymorphic_json")
}
@patjackson52
patjackson52 / LandingPage.java
Created April 9, 2013 14:24
GWT-Bootstrap implementation of the masthead as shown in the twitter bootstrap marketing example. The second file is how to use the Masthead.
MastHead mastHead=new MastHead();
NavLink logIn=new NavLink("Log In");
NavLink aboutButton=new NavLink("About");
mastHead.setText("My Awesome App");
mastHead.setSubtext("Subtitle");
mastHead.addButton(logIn);
mastHead.addButton(aboutButton);