Once
Once is an object that will perform exactly one action.
-
Returns a new Once.
Declaration
Swift
public init() {}
-
Calls the
action
if and only ifdoit
is being called for the first time for this instance ofOnce
. In other words, givenvar once Once
If
doit
is called multiple times, only the first call will invokeaction
, even ifaction
has a different value in each invocation. A new instance ofOnce
is required for each function to execute.This method is intended for initialization that must be run exactly once.
Declaration
Swift
public func doit(action: ()->())