dalu93 / each Goto Github PK
View Code? Open in Web Editor NEWElegant ⏱ interface for Swift apps
License: MIT License
Elegant ⏱ interface for Swift apps
License: MIT License
Actually the return type is Bool
timer.perform {
// return `true` if you want to stop the timer, otherwise `false` to continue
}
In an implemented way where we want to stop the timer after doing something()
, the code below isn't readable by other developers
timer.perform {
self.something()
return true // what does true mean? To continue it or to stop it?
}
A better way could be to declare an enum NextStep
(as mentioned by @DeveloperPans) which encapsulates better the return type's meaning
enum NextStep {
case stop
case `continue`
}
Which has a fileprivate
extension that converts the enum to a Bool
for the perform closure.
The final result for the user will be
timer.perform {
self.something()
return .stop/.continue
}
My 'Podfile':
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'XXX' do
use_frameworks!
pod 'Each', '~> 1.2'
end
And, pod install
the error is
[!] Unable to satisfy the following requirements:
- `Each (~> 1.2)` required by `Podfile`
None of your spec sources contain a spec satisfying the dependency: `Each (~> 1.2)`.
You have either:
* out-of-date source repos which you can update with `pod repo update`.
* mistyped the name or version.
* not added the source repo that hosts the Podspec to your Podfile.
Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
but, if I delete pod 'Each', '~> 1.2'
the other pods is available
As for the title, a Carthage
compatibility would be great.
To workaround the memory leak issue, an another idea could be to implement the famous pattern of Disposable
and Disposer
// MARK: - Disposable declaration
public protocol Disposable {
func dispose()
}
// MARK: - Disposable
extension Each: Disposable {
public func dispose() {
stop()
}
}
// MARK: - Disposer declaration
public protocol Disposer {
func add(_ disposable: Disposable)
func dispose()
}
Hi,
I would like to add "Each" to my RSS feed – is that okey?
https://github.com/MKGitHub/TheSwiftSweets
RunLoop retain Each's _timer
property cause memory Leaks, Although _timer
be marked as weak
.
RunLoop -> Timer -> Each
Seconde to milliseconds should be 1/1000, nog 1/60.
If the interface contains any scrollable item (table view, collection view, etc), then timer stops firing events while user scrolls the content.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.