Schedule
Schedule is a timing tasks scheduler written in Swift. It allows you run timing tasks with elegant and intuitive syntax.
Features
- [x] Elegant and intuitive API
- [x] Rich preset rules
- [x] Powerful management mechanism
- [x] Detailed execution history
- [x] Thread safe
- [x] Complete documentation
- [x] ~100%+ test coverage
Why You Should Use Schedule
Features | Timer | DispatchSourceTimer | Schedule |
---|---|---|---|
⏰ Interval-based Schedule | ✓ | ✓ | ✓ |
? Date-based Schedule | ✓ | ✓ | |
? Combined Plan Schedule | ✓ | ||
?️ Natural Language Parse | ✓ | ||
? Batch Task Management | ✓ | ||
? Execution Record | ✓ | ||
? Plan Reset | ✓ | ✓ | |
? Suspend, Resume, Cancel | ✓ | ✓ | |
? Child-action | ✓ |
Usage
Overview
Scheduling a task has never been so elegant and intuitive, all you have to do is:
Rules
Interval-based Schedule
The running mechanism of Schedule is based on Plan
, and Plan
is actually a sequence of Interval
.
Schedule makes Plan
definitions more elegant and intuitive by extending Int
and Double
. Also, because Interval
is a built-in type of Schedule, you don't have to worry about it being polluting your namespace.
Date-based Schedule
Configuring date-based Plan
is the same, with the expressive Swift syntax, Schedule makes your code look like a fluent conversation.
Natural Language Parse
In addition, Schedule also supports simple natural language parsing.
Combined Plan Schedule
Schedule provides several basic collection operators, which means you can use them to customize your own powerful plans.
Management
DispatchQueue
When calling plan.do
to dispatch a timing task, you can use queue
to specify which DispatchQueue
the task will be dispatched to when the time is up. This operation does not rely on RunLoop
like Timer
, so you can call it on any thread.
RunLoop
If queue
is not specified, Schedule will use RunLoop
to dispatch the task, at which point the task will execute on the current thread. Please note, like Timer
, which is also based on RunLoop
, you need to ensure that the current thread has an available RunLoop
. By default, the task will be added to .common
mode, you can specify another mode when creating the task.
Timeline
You can observe the execution record of the task in real time using the following properties.
TaskCenter & Tag
Tasks are automatically added to TaskCenter.default
by default,you can organize them using tags and task center.
Suspend,Resume, Cancel
You can suspend
, resume
, cancel
a task.
Action
You can add more actions to a task and remove them at any time you want:
Installation
CocoaPods
Carthage
github "luoxiu/Schedule" ~> 2.0
Swift Package Manager
Contributing
Like Schedule? Thanks!!!
At the same time, I need your help~
Finding Bugs
Schedule is just getting started. If you could help the Schedule find or fix potential bugs, I would be grateful!
New Features
Have some awesome ideas? Feel free to open an issue or submit your pull request directly!
Documentation improvements.
Improvements to README and documentation are welcome at all times, whether typos or my lame English, ?.
Acknowledgement
Inspired by Dan Bader's schedule!