Latest 2.0.3
Homepage https://github.com/guoyingtao/Trigger
License MIT
Platforms ios 10.0
Authors

Swift Trigger

swift 5.0 badgeplatform iOS badgelicense MIT badgebuild status

SwiftTrigger is used to easily check if some events should be trigged by executing times:

  • The first time run
  • The Nth time run
  • every Nth times run
  • every Nth times run but stops after repeating M times

Events Storage

Behind the scene, SwiftTrigger uses coredata to save events. All the coredata files are in its own folder whose default name is "SwiftTriggerDB". You can always change it by setting SwiftTrigger.Config.containerFolder to your favorite name.

Requirements

  • iOS 10.0+
  • Xcode 9.0+

Install

CocoaPods

To integrate SwiftTrigger into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'SwiftTrigger', '~> 2.0.3'

Cathage

github "guoyingtao/Trigger"

Usage

Create an event triggered only for the first time run

SwiftTrigger().oneshotCheck("MyEvent") {
  // do something
}

Create an event triggered for the Nth time run then stop triggering after that

let event = SwiftTrigger.Event(id: "MyEvent", targetRunningTimes: N)
SwiftTrigger().monitor(event) { {
  // do something
}

Create an event triggered for the every Nth times run

let event = SwiftTrigger.Event(id: "MyEvent", targetRunningTimes: N, repeatTimes: 0)
SwiftTrigger().monitor(event) {
  // do something
}

Create an event triggered for the every Nth times fun but stop triggering after the event repeated for M times

let event = SwiftTrigger.Event(id: "MyEvent", targetRunningTimes: N, repeatTimes: M)
SwiftTrigger().monitor(event) {
  // do something
}

Clear triggers for events

let event1 = "MyEvent1"
let event2 = "MyEvent2"
SwiftTrigger().clearEvent(by: event1)
SwiftTrigger().clearEvents(by: event1, event2)
SwiftTrigger().clearEvents(by: [event1, event2])
SwiftTrigger().clearAll()

Latest podspec

{
    "name": "SwiftTrigger",
    "version": "2.0.3",
    "summary": "SwiftTrigger is used to easily check if some events should be trigged by executing times.",
    "description": "The event can be trigged by following casesn* The first time runn* The N time runn* every N times runn* every N times run but stop after repeating M times",
    "homepage": "https://github.com/guoyingtao/Trigger",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yingtao Guo": "[email protected]"
    },
    "social_media_url": "http://twitter.com/guoyingtao",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/guoyingtao/Trigger.git",
        "tag": "2.0.3"
    },
    "source_files": "SwiftTrigger/*.swift",
    "resources": "SwiftTrigger/*.xcdatamodeld"
}

Pin It on Pinterest

Share This