RxXRepository: reactive extension for XRepository

Related tags

Event RxXRepository
Overview


Supported Platforms: iOS, macOS, tvOS, watchOS

RxXRepository is reactive extension for XRepository. This extension allows implementations of Repository pattern become rx-compatable and adds observing methods to CRUD operations.

👋🏻 Getting started

Cornerstone of this project is RxRepository protocol.

protocol RxRepository {
  associatedtype Model
  func observeAll() -> Observable<AnyRandomAccessCollection<Model>>
  func observeElement<Id>(withId id: Id) -> Observable<Model>
  func observeElements(filteredBy filter: Query<Model>?, sortedBy sortKeyPath: ComparableKeyPath<Model>?, distinctUsing distinctMode: HashableKeyPath<Model>?) ->  Observable<AnyRandomAccessCollection<Model>>
  func getAll() -> Single<AnyRandomAccessCollection<Model>>
  func getElement<Id>(withId id: Id) -> Single<Model?>
  func getElements(filteredBy filter: Query<Model>?, sortedBy sortMode: ComparableKeyPath<Model>?, distinctUsing distinctMode: HashableKeyPath<Model>?) -> Single<AnyRandomAccessCollection<Model>>
  func create(_ model: Model) -> Single<Model>
  func create(_ models: [Model]) -> Single<[Model]>
  func update(_ model: Model) -> Single<Model>
  func delete(_ model: Model) -> Completable
  func delete(_ models: [Model]) -> Completable
  func deleteAll() -> Completable
  func performTransaction(_ transaction: @escaping () -> Void) -> Completable
}

Than you have AnyRxRepository class to abstragate implementation of Repository & RxRepository from its consumers. AnyRxRepository has the same semantic as its interface. It consumes implementation of both Repository & RxRepository.

final class AnyRxRepository<Model>: Repository {
  ...
  init <A: Repository & RxRepository>(_ repository: A) where A.Model == Model { ... }
  ...
}

🔧 Usage

Since RxXRepository is an extension of XRepository, you can extend functionality of existing Repository implementation. Right now you get out-of-the-box extension for UserDefaultsRepository. But you can create your own implementation. While non-reactive interface has not changed from XRepository, you get access to rx methods by subscripting repository instance with rx. Usage is simple:

class ChurchesViewModel {
  ...
  let churchesRepository: AnyRxRepository<Church>
  ...

  func foo() {
  let result = churchesRepository.getAll()
  let rxResult = churchesRepository.rx.getAll()
  }
}

let churchesStorage = AnyRxRepository(UserDefaultsRepository<Church>())
let churchesViewModel = ChurchesViewModel(churchesRepository: churchesStorage)

If you want a pure reactive repository implementations for popular storages, check my latest project: ReactiveXRepository

👤 Author

This framework is created by Sashko Potapov.

📃 License

XCoordinator is released under an MIT license. See License.md for more information.

You might also like...
 Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.
Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.

ReactiveSwift offers composable, declarative and flexible primitives that are built around the grand concept of streams of values over time. These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation.

A library for reactive and unidirectional Swift applications
A library for reactive and unidirectional Swift applications

ReactorKit is a framework for a reactive and unidirectional Swift application architecture. This repository introduces the basic concept of ReactorKit

RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.
RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.

About Architecture concerns RxReduce Installation The key principles How to use RxReduce Tools and dependencies Travis CI Frameworks Platform Licence

A reactive, card-based UI framework built on UIKit for iOS developers.
A reactive, card-based UI framework built on UIKit for iOS developers.

CardParts - made with ❤️ by Intuit: Example Requirements Installation Communication & Contribution Overview Quick Start Architecture CardsViewControll

Reactive WebSockets

RxWebSocket Reactive extensions for websockets. A lightweight abstraction layer over Starscream to make it reactive. Installation RxWebSocket is avail

Reactive Programming in Swift
Reactive Programming in Swift

Rx is a generic abstraction of computation expressed through ObservableElement interface, which lets you broadcast and subscribe to values and other

A reactive library for using URLSession

Reactive wrapper for URLSession using Combine. At its core, the library consist of the NetworkServiceClient protocol along with a minimal implementation NetworkService.

🚦 Validation library depends on SwiftUI & Combine. Reactive and fully customizable.

🚦 Validation library depends on SwiftUI & Combine. Reactive and fully customizable.

Declarative and Reactive Networking for Swift.

Squid Squid is a declarative and reactive networking library for Swift. Developed for Swift 5, it aims to make use of the latest language features. Th

A New, Modern Reactive State Management Library for Swift and SwiftUI (The iOS implementation of Recoil)
A New, Modern Reactive State Management Library for Swift and SwiftUI (The iOS implementation of Recoil)

RecoilSwift RecoilSwift is a lightweight & reactive swift state management library. RecoilSwift is a SwiftUI implementation of recoil.js which powered

A reactive wrapper built around UIImagePickerController.

RxMediaPicker RxMediaPicker is a RxSwift wrapper built around UIImagePickerController consisting in a simple interface for common actions like picking

A Swift Reactive Programming Kit
A Swift Reactive Programming Kit

ReactiveKit is a lightweight Swift framework for reactive and functional reactive programming that enables you to get into the reactive world today. T

RxSwift reactive wrapper for view gestures
RxSwift reactive wrapper for view gestures

RxGesture Usage To run the example project, clone the repo, in the Example folder open RxGesture.xcworkspace. You might need to run pod install from t

Simple and lightweight Functional Reactive Coding in Swift for the rest of us
Simple and lightweight Functional Reactive Coding in Swift for the rest of us

The simplest ObservableT implementation for Functional Reactive Programming you will ever find. This library does not use the term FRP (Functional R

Reactive Keyboard in iOS
Reactive Keyboard in iOS

RxKeyboard RxKeyboard provides a reactive way of observing keyboard frame changes. Forget about keyboard notifications. It also perfectly works with U

Reactive WebSockets

RxWebSocket Reactive extensions for websockets. A lightweight abstraction layer over Starscream to make it reactive. Installation RxWebSocket is avail

RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.
RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.

About Architecture concerns RxReduce Installation The key principles How to use RxReduce Tools and dependencies Travis CI Frameworks Platform Licence

A Swift framework for reactive programming.

CwlSignal An implementation of reactive programming. For details, see the article on Cocoa with Love, CwlSignal, a library for reactive programming. N

Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.
Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.

iOS (Swift 5): Test MVVM avec Combine et UIKit L'architecture MVVM et la programmation réactive fonctionnelle sont très utlisées dans le développement

Releases(1.0.0)
Owner
Sashko Potapov
Software Engineer with deep interest in RFP and Blockchain.
Sashko Potapov
A library for reactive and unidirectional Swift applications

ReactorKit is a framework for a reactive and unidirectional Swift application architecture. This repository introduces the basic concept of ReactorKit

ReactorKit 2.5k Dec 28, 2022
RxReduce is a lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way.

About Architecture concerns RxReduce Installation The key principles How to use RxReduce Tools and dependencies Travis CI Frameworks Platform Licence

RxSwift Community 125 Jan 29, 2022
A New, Modern Reactive State Management Library for Swift and SwiftUI (The iOS implementation of Recoil)

RecoilSwift RecoilSwift is a lightweight & reactive swift state management library. RecoilSwift is a SwiftUI implementation of recoil.js which powered

Holly Li 160 Dec 25, 2022
XRepository: lightweight implementation of Repository pattern in Swift

XRepository is based on QBRepository by QuickBirds Studios. It is lightweight im

Sashko Potapov 2 Jan 10, 2022
Reactive WebSockets - A lightweight abstraction layer over Starscream to make it reactive.

RxWebSocket Reactive extensions for websockets. A lightweight abstraction layer over Starscream to make it reactive. Installation RxWebSocket is avail

Flávio Caetano 57 Jul 22, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022
Reactant is a reactive architecture for iOS

Reactant Reactant is a foundation for rapid and safe iOS development. It allows you to cut down your development costs by improving reusability, testa

Brightify 374 Nov 22, 2022
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Spinners 119 Dec 29, 2022
RxFlow is a navigation framework for iOS applications based on a Reactive Flow Coordinator pattern

About Navigation concerns RxFlow aims to Installation The key principles How to use RxFlow Tools and dependencies GitHub Actions Frameworks Platform L

RxSwift Community 1.5k May 26, 2021
A complete set of primitives for concurrency and reactive programming on Swift

A complete set of primitives for concurrency and reactive programming on Swift 1.4.0 is the latest and greatest, but only for Swift 4.2 and 5.0 use 1.

AsyncNinja 156 Aug 31, 2022