All Projects → Malinskiy → Sheldon

Malinskiy / Sheldon

Licence: other
Type-safe reactive preferences for Android

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Sheldon

Rx.Http
A reactive way to make HTTP Request in .NET Core 🚀
Stars: ✭ 62 (+82.35%)
Mutual labels:  reactive, rx
mono-reactive
open source Reactive Extensions (Rx) implementation for Mono
Stars: ✭ 65 (+91.18%)
Mutual labels:  reactive, rx
reactify
The first and only true Functional Reactive Programming framework for Scala.
Stars: ✭ 77 (+126.47%)
Mutual labels:  reactive, rx
callbag-subscribe
A callbag sink (listener) that connects an Observer a-la RxJS. 👜
Stars: ✭ 17 (-50%)
Mutual labels:  reactive, rx
Rxgps
Finding current location cannot be easier on Android !
Stars: ✭ 307 (+802.94%)
Mutual labels:  reactive, rx
purescript-outwatch
A functional and reactive UI framework based on Rx and VirtualDom
Stars: ✭ 33 (-2.94%)
Mutual labels:  reactive, rx
Reactive.XAF
DevExpress XAF extension framework. 𝗹𝗶𝗻𝗸𝗲𝗱𝗶𝗻.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺, 𝘆𝗼𝘂𝘁𝘂𝗯𝗲.𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸.𝗰𝗼𝗺 and 𝘁𝘄𝗶𝘁𝘁𝗲𝗿 @𝗲𝘅𝗽𝗮𝗻𝗱𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 and or simply 𝗦𝘁𝗮𝗿/𝘄𝗮𝘁𝗰𝗵 this repository and get notified from 𝗚𝗶𝘁𝗛𝘂𝗯
Stars: ✭ 60 (+76.47%)
Mutual labels:  reactive, rx
Rxviz
Rx Visualizer - Animated playground for Rx Observables
Stars: ✭ 1,471 (+4226.47%)
Mutual labels:  reactive, rx
Toy Rx
A tiny implementation of RxJS that actually works, for learning
Stars: ✭ 290 (+752.94%)
Mutual labels:  reactive, rx
Rxkprefs
🛠 A small Kotlin library to make shared preferences easy + RxJava and Coroutines support
Stars: ✭ 264 (+676.47%)
Mutual labels:  reactive, rx
redrock
Typesafe, reactive redux
Stars: ✭ 14 (-58.82%)
Mutual labels:  reactive, rx
Combinex
Open source implementation for Apple's Combine
Stars: ✭ 496 (+1358.82%)
Mutual labels:  reactive, rx
Aesthetic
[DEPRECATED]
Stars: ✭ 2,044 (+5911.76%)
Mutual labels:  reactive, rx
InterReact
Interactive Brokers reactive C# API.
Stars: ✭ 28 (-17.65%)
Mutual labels:  reactive, rx
Qactive
Reactive queryable observable framework.
Stars: ✭ 147 (+332.35%)
Mutual labels:  reactive, rx
fpEs
Functional Programming for EcmaScript(Javascript)
Stars: ✭ 40 (+17.65%)
Mutual labels:  reactive, rx
Android Okgraphql
Reactive GraphQl client for Android
Stars: ✭ 64 (+88.24%)
Mutual labels:  reactive, rx
Rx Connect
Glue your state and pure React components with RxJS
Stars: ✭ 86 (+152.94%)
Mutual labels:  reactive, rx
Binder
An Annotation processor that allows binding two classes with each other, where the first class can listen to the updates of the second class ... ideal for MVVM and similar patterns
Stars: ✭ 21 (-38.24%)
Mutual labels:  reactive, rx
Outwatch
A purely functional and reactive UI framework
Stars: ✭ 376 (+1005.88%)
Mutual labels:  reactive, rx

Build Status Android Arsenal Join the chat at https://gitter.im/Malinskiy/Sheldon Maven Central

Sheldon

Key concepts:

  • Preferences should not be tied to concrete implementation, they should be an interface that you can easily mock in your tests
  • You should be able to provide implementation gateway in your platform layer
  • Get your values through RxJava's Observable
  • Get rid of always specifying a string key when you get or set preference, this should be strongly typed so that your IDE can help with autocompletion and your key<->value pair is always in sync
  • Leverage annotation processing to automatically generate the wiring code between your preferences and platform gateway

Define your interface:

@Preferences(name = "temp")
public interface SomePreferences {
    @Default(name = "name") String DEFAULT_VALUE = "DEFAULT_VALUE";
    @Get(name = "name") Observable<String> getValueName();
    @Set(name = "name") void setValue(String newValue);
    ...
    @Contains Observable<Boolean> contains(String key);
    @Delete void remove(String key);
}

Adapters

Natively supported types are Boolean, Float, Integer, Long and String.

For everything else you have to extend IPreferenceAdapter and implement storing your entity via supported types. You can look at example of generic EnumAdapter. To include your adapter into processing just annotate it with @Adapter.

Each adapter should have a no-args constructor

Defaults

For each parameter you have to always supply a default value as a field in an interface annotated with @Default. Type of parameter should be the same as in getter and setter.

Instantiate the generated implementation

Temp_Preferences preferences = new Temp_Preferences(new SharedPreferencesGatewayBuilder(contextRef));

Probably you'd store this in your dependency graph and inject it by interface For additional info look at the sample

Get it

Gradle:

repositories {
    ...
    mavenCentral()
    ...
}
...
dependencies {
    ...
    apt "com.malinskiy.sheldon2:compiler:$version"
    compile "com.malinskiy.sheldon2:core:$version"
    compile "com.malinskiy.sheldon2:gateway-sharedpreferences:$version"
    ...
}

License

Copyright 2017 Anton Malinskiy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and   limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].