Latest 0.1.0
Homepage https://github.com/devandsev/JustSignals
License MIT
Platforms ios 8.0, osx 10.9
Frameworks Foundation
Authors

Build Status

JustSignals is a type-safe alternative to NotificationCenter and delegates. Use it if you don’t need binding and rx magic in your project, and just want to replace NotificationCenter with something more strict and safe. Otherwise take a look at RxSwift, ReactiveCocoa and Bond.

Installation

CocoaPods

  # Podfile
  use_frameworks!

  target 'YOUR_TARGET_NAME' do
      pod 'JustSignals'
  end

Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:

  $ pod install

Carthage

Add this to Cartfile

  github "devandsev/JustSignals"

In the Cartfile directory, type:

  $ carthage update

Usage examples

Signal without any data:

  let signal = Signal<Void>()
  signal.subscribe(with: self) {
      print("pong")
  }

  signal.fire(())

Signal with data:

  let signal = Signal<Int>()
  signal.subscribe(with: self) { data in
      print(data)
  }

  signal.fire(36)

If you need to pass multiple values:

  let signal = Signal<(Int, Float, String, Bool)>()
  signal.subscribe(with: self) { data in
      print(data)
  }

  signal.fire((3, 2.2, "test", false))

Subscription cancels automatically if the object that has been subscribed to the signal is deallocated, but if you need to unsubscribe early, use this:

  signal.unsubscribe(self)

License

This project is licensed under the MIT License – see the LICENSE file for details.

Latest podspec

{
    "name": "JustSignals",
    "version": "0.1.0",
    "summary": "Signals to replace delegates and NotificationCenter, nothing more.",
    "description": "JustSignals is a type-safe alternative to NotificationCenter and delegates.nUse it if you don't need binding and rx magic in your project,nand just want to replace NotificationCenter with something more strict and safe.",
    "homepage": "https://github.com/devandsev/JustSignals",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Andrey Sevrikov": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9"
    },
    "source": {
        "git": "https://github.com/devandsev/JustSignals.git",
        "tag": "0.1.0"
    },
    "source_files": "Sources/*",
    "frameworks": "Foundation",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This