Latest 0.2.0
Homepage https://github.com/rxpipe/UndoProxy
License MIT
Platforms ios 9.0, tvos 9.0, osx 10.10, watchos 3.0, requires ARC
Dependencies RxSwift, RxCocoa
Authors

Version
License
Platform

Manaul

import UndoProxy

enum Action: Undoable {
    case add(_ num: Int)
    case minus(_ num: Int)

    var opposite: Action {
        switch self {
        case .add(let val): return .minus(val)
        case .minus(let val): return .add(val)
        }
    }
}

class Calculator {
    var undoProxy = UndoProxy<Action>()
    var value: Int
    let disposeBag = DisposeBag()

    init(value: Int) {
        self.value = value
        undoProxy.signal
            .subscribe(onNext: { (action) in
                switch action {
                case .add(let val):
                    self.value += val
                case .minus(let val):
                    self.value -= val
                }
            })
            .disposed(by: disposeBag)
    }

    func API() {
      undoProxy.register(.add(1))
      undoProxy.dispatch(.add(1))
      undoProxy.dispatch([.add(1), .add(2)])
      undoProxy.canUndo
      undoProxy.canRedo
      undoProxy.undo()
      undoProxy.redo()
    }
}

Installation

Cocoapods

pod 'UndoProxy', '~> 0.1'

Swift Package Manager

.package(url: "https://github.com/rxpipe/UndoProxy.git")

Author

duan, [email protected]

License

RxTheme is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "UndoProxy",
    "version": "0.2.0",
    "swift_versions": "5.0",
    "summary": "Undo manager with declarative taste",
    "description": "Imperative styled Undo manager can easily create retain cycle and create bugs. UndoProxy uses a declarative way to manage undo and redo stack.",
    "homepage": "https://github.com/rxpipe/UndoProxy",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "wddwycc": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rxpipe/UndoProxy.git",
        "tag": "0.2.0"
    },
    "social_media_url": "https://twitter.com/wddwycc",
    "platforms": {
        "ios": "9.0",
        "tvos": "9.0",
        "osx": "10.10",
        "watchos": "3.0"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*",
    "dependencies": {
        "RxSwift": [
            "~> 5.0"
        ],
        "RxCocoa": [
            "~> 5.0"
        ]
    }
}

Pin It on Pinterest

Share This