A MVVM Project using two way binding with DidSet swift feature

Overview

FawryTask

Description

Fawry Task is a MVVM Project using two way binding with DidSet swift feature , follow Solid princepl by uncle bob esecially Single Responsibility principle and dependency inversion Principle.

Bindable

import Foundation
public class Bindable<BindType> {
    public typealias Listener = ((BindType) -> Void)
    
    private var listeners: [(identifier: UUID, listener: Listener)] = []
    
    public var value: BindType {
        didSet {
            notifyListeners(value)
        }
    }
    
    public init(_ v: BindType) {
        value = v
    }
    
    public func bind(_ listener: @escaping Listener) -> BindDisposable {
        let listenerId = UUID()
        let disposable = BindDisposable(onDispose: { [weak self] in
            self?.removeListener(with: listenerId)
        })
        
        self.listeners.append((identifier: listenerId, listener: listener))
        
        return disposable
    }
    
    public func bindAndFire(_ listener: @escaping Listener) -> BindDisposable {
        let disposable = self.bind(listener)
        listener(value)
        return disposable
    }
    
    private func removeListener(with id: UUID) {
        self.listeners.removeAll(where: { $0.identifier == id })
    }
    
    private func notifyListeners(_ value: BindType) {
        self.listeners.forEach({ $0.listener(value) })
    }
}

public class BindDisposable {
    
    private let onDispose: (() -> Void)
    
    init(onDispose: @escaping () -> Void) {
        self.onDispose = onDispose
    }
    
    public func dispose() {
        onDispose()
    }
    
    deinit {
        dispose()
    }
}

public struct DisposableBag {
    
    private var disposables: [BindDisposable] = []
    
    public init() {
        
    }
    public mutating func add(_ disposable: BindDisposable?) {
        
        guard let disposable = disposable else {
            return
        }
        disposables.append(disposable)
    }
}

Installation

$ pod install
You might also like...
RippleQueries is an iOS application built as assessment task at Ripple Egypt. Built Using MVVM (Model-View-ViewModel) and Clean Architecture concepts
RippleQueries is an iOS application built as assessment task at Ripple Egypt. Built Using MVVM (Model-View-ViewModel) and Clean Architecture concepts

RippleRepositories RippleRepositories is an iOS application built as an assessment task at Ripple Egypt. Built Using RxSwift & MVVM (Model-View-ViewMo

NearMe Locations iOS App Using MVVM with Closure
NearMe Locations iOS App Using MVVM with Closure

NearMe Locations iOS App App display information about nearby places around user using user’s current location specified by Latitude and Longitude Imp

In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

A SwiftUI Application using MVVM, Core Data and Combine
A SwiftUI Application using MVVM, Core Data and Combine

SwiftUI | Breaking Bad App Application that shows the characters of Breaking Bad.

A mobile application project designed for everybody which provides the easiest way to make searchs for public services
A mobile application project designed for everybody which provides the easiest way to make searchs for public services

A mobile application project designed for everybody which provides the easiest way to make searchs for public services

Don't start from scratch, start from Here! This is a starter project for iOS projects. It contains all the basic configurations and common libraries for your project.

Starter-iOS Don't start from scratch, start from Here! This is a starter project for iOS projects. It contains all the basic configurations and common

NewsAPI-Project - News API Project For iOS
NewsAPI-Project - News API Project For iOS

NewsAPI-Project Es necesario descargar y realizar un pod install para ejecutar e

Stocks APP With MVVM,Swift
Stocks APP With MVVM,Swift

Stocks Light Mode Dark Mode Unit tests Initial Build Setup for iOS App Clone the project. Xcode 13 installed. iOS 15 or above. Carthage v0.38.0 instal

Owner
null
An iOS template project using SwiftUI, Combine and MVVM-C software architecture

SwiftUI-MVVM-C A template project that uses SwiftUI for UI, Combine for event handling, MVVM-C for software architecture. I have done some small proje

Huy Nguyen 107 Jan 2, 2023
App which lets two people share their social media details by simply putting one phone on top of the other ("tapping"). Currently in development by Nikita Mounier.

Tap It Tap It enables two people to seamlessly share their social media information (e.g. Instagram, Snapchat, phone number) by simply placing one scr

Nikita Mounier 24 Oct 21, 2022
A swift package(SPM) with iOS UI component that loads and displays images from remote urls or local assets and displays in a slide-show form with auto scroll feature.

MDBannersView A swift package with an iOS UI component that loads and displays images from remote urls, local assets and displays in a slide-show form

Madhav Deva 2 Feb 5, 2022
GroceryMartApp-iOS-practice - To Practice fundamental SwiftUI feature like navigation, state mamagement, customazing etc

?? GroceryMartApp-iOS-practice 아래의 내용은 스윗한 SwiftUI 책의 실전 앱 구현하기 을 바탕으로 정리한 내용입니다

Jacob Ko 0 Jan 7, 2022
Ios-exercise - In this exercise applicant should implement a new feature into an existing sample app

Cooking app In this exercise applicant should implement a new feature into an ex

Kristīne 0 Feb 7, 2022
Github repo search with using mvvm-c and clean architecture and using combine swift

GitSearchWithMVVM-C-CleanArchitecture Github repo search with using mvvm-c and clean architecture and using combine swift. Content Overview How To Run

Muhammad Qasim Majeed 1 Mar 16, 2022
Implemented MVVM-C (Coordinator) architecture pattern for the project. Which is satisfying SOLID principles altogether. Protocol oriented development has been followed.

BreakingBad BreakingBad API doc Implemented MVVM-C (Coordinator) architecture pattern for the project. Which is satisfying SOLID principples altogethe

Dhruvik Rao 2 Mar 10, 2022
SwiftUI-TodoList - This project uses MVVM architecture and UserDefaults to persist data

SwiftUI-TodoList | ├── SwiftUITodoList | ├── Library | ├── Models

Yezan Ahmed 0 Mar 9, 2022
Lentit iOS app developed in Swift with SwiftUI using MVVM design pattern

Lentit Track things you lend with Lentit Features 100% Swift 100% SwiftUI MVVM d

W1W1-M 2 Jun 26, 2022
IOS e-commerce app developed using MVVM architecture with Swift UI

IOS e-commerce app developed using MVVM architecture with Swift UI.

wykee2 1 Apr 2, 2022