-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from surfstudio/#7_add_special_initialization
#7 add special initialization
- Loading branch information
Showing
20 changed files
with
359 additions
and
755 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- "CoreEvents/CoreEvents/Sources/Base" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
Pod::Spec.new do |s| | ||
|
||
s.name = "CoreEvents" | ||
s.version = "1.3.0" | ||
s.summary = "Small library contains rx-like events." | ||
s.name = "CoreEvents" | ||
s.version = "2.0.0" | ||
s.summary = "Small library contains rx-like events." | ||
|
||
s.description = <<-DESC | ||
This library contains object represents Events (like C# event). | ||
This may simplify things like: pub/sub, delegation, notification and other. | ||
DESC | ||
|
||
s.homepage = "https://github.com/surfstudio/CoreEvents" | ||
s.homepage = "https://github.com/surfstudio/CoreEvents" | ||
|
||
s.license = { :type => "MIT" } | ||
s.license = { :type => "MIT" } | ||
|
||
s.author = { "Alexander Kravchenkov" => "a.a.kravchenkov@gmail.com" } | ||
s.author = { "Alexander Kravchenkov" => "a.a.kravchenkov@gmail.com" } | ||
|
||
s.ios.deployment_target = "9.0" | ||
|
||
#s.osx.deployment_target = "10.10" | ||
s.source = { :git => "https://github.com/surfstudio/CoreEvents.git", :tag => "#{s.version}" } | ||
|
||
s.source = { :git => "https://github.com/surfstudio/CoreEvents.git", :tag => "#{s.version}" } | ||
|
||
s.source_files = 'CoreEvents/CoreEvents/Sources/**/*.swift' | ||
s.source_files = 'CoreEvents/CoreEvents/Sources/**/*.swift' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/// Абстрактный класс для события. | ||
open class Event<Input> { | ||
|
||
/// Тип для замыкания события. | ||
public typealias Closure = (Input) -> Void | ||
|
||
internal init() { } | ||
|
||
/// Добавляет нового слушателя для события. | ||
/// Слушатель добавляется `безопасно` - по ключу. | ||
/// В качестве ключа по-умолчанию берется путь до файла из которого был вызыван метод. | ||
/// - Warning: Внутри одного файла для одного события нельзя добавлять несколько слушателей без явного указания ключа. | ||
/// В противном случае события будут перезаписаны. | ||
/// Если вам необходимо внутри одного файла добавить больше одного слушателя - используйте собственные ключи | ||
/// - Parameters: | ||
/// - key: Ключ для добавления нового слушателя. | ||
/// - listner: Слушатель. | ||
open func add(key: String = #file, _ listner: @escaping Closure) { | ||
fatalError("\(#function) should be overriden in child class") | ||
} | ||
|
||
/// Оповещает всех подписчиков данного события. | ||
/// | ||
/// - Parameter input: Данные, которые нужно предать подписчикам. | ||
open func invoke(with input: Input) { | ||
fatalError("\(#function) should be overriden in child class") | ||
} | ||
|
||
/// Оповещает конкретного подписчика. | ||
/// | ||
/// - Parameters: | ||
/// - input: Данные, которые будут переданы подписчику. | ||
/// - key: Ключ подписчика, которого нужно оповестить. | ||
open func invoke(with input: Input, key: String = #file) { | ||
fatalError("\(#function) should be overriden in child class") | ||
} | ||
|
||
/// Удаляет всех подписчиков. | ||
open func clear() { | ||
fatalError("\(#function) should be overriden in child class") | ||
} | ||
|
||
/// Удаляет конкретного подписчика. | ||
/// Ожидается тот же ключ, что ыл добавлен в `add(by key: String = #file, _ listner: @escaping Closure)` | ||
/// | ||
/// - Parameter key: Ключ подписчика. По-умолчанию это `#file` так же как и для `addListener` | ||
open func remove(key: String = #file) { | ||
fatalError("\(#function) should be overriden in child class") | ||
} | ||
} | ||
|
||
public extension Event where Input == Void { | ||
|
||
/// Синтаксический сахар. Позоляет вызвать слушателей без передачи параметра если `Input == Void` | ||
func invoke() { | ||
self.invoke(with: ()) | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
CoreEvents/CoreEvents/Sources/FutureEvents/FutureEmptyEvent.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
CoreEvents/CoreEvents/Sources/FutureEvents/FutureValueEvent.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.