Skip to content

Commit

Permalink
Fix Property method ambiguity issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed May 23, 2016
1 parent fc47ffc commit 3584c0e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ReactiveKit.podspec
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Pod::Spec.new do |s|
s.name = "ReactiveKit"
s.version = "2.0.0"
s.version = "2.0.1"
s.summary = "A Swift Reactive Programming Framework"
s.description = "ReactiveKit is a collection of Swift frameworks for reactive and functional reactive programming."
s.homepage = "https://github.com/ReactiveKit/ReactiveKit"
s.license = 'MIT'
s.author = { "Srdan Rasic" => "[email protected]" }
s.source = { :git => "https://github.com/ReactiveKit/ReactiveKit.git", :tag => "v2.0.0" }
s.source = { :git => "https://github.com/ReactiveKit/ReactiveKit.git", :tag => "v2.0.1" }

s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
Expand Down
2 changes: 1 addition & 1 deletion ReactiveKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.0</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
9 changes: 8 additions & 1 deletion Sources/CollectionProperty.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public extension CollectionChangesetType where Collection.Index: Equatable {
}
}

public protocol CollectionPropertyType: CollectionType, StreamType, PropertyType {
public protocol CollectionPropertyType: CollectionType, StreamType, PropertyType, SubjectType {
associatedtype Collection: CollectionType
associatedtype Index = Collection.Index
associatedtype Member = Collection.Generator.Element
Expand Down Expand Up @@ -202,6 +202,13 @@ public class CollectionProperty<C: CollectionType>: CollectionPropertyType {
collection = changeset.collection
subject.on(.Next(changeset))
}

public func on(event: StreamEvent<CollectionChangeset<C>>) {
if let changeset = event.element {
collection = changeset.collection
}
subject.on(event)
}
}

public extension CollectionPropertyType {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public final class Property<T>: PropertyType, StreamType, SubjectType {
_value = value
}

public func silentUpdate(value: T) {
_value = value
}

deinit {
subject.completed()
}
Expand Down
16 changes: 9 additions & 7 deletions Sources/Subjects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ internal class ObserverRegister<E: EventType> {
}
}

public protocol SubjectType: ObserverType, RawStreamType {
func on(event: Event)
public protocol SubjectType: ObserverType, _StreamType {
}

public final class PublishSubject<E: EventType>: ObserverRegister<E>, SubjectType {
public protocol RawSubjectType: ObserverType, RawStreamType {
}

public final class PublishSubject<E: EventType>: ObserverRegister<E>, RawSubjectType {

private let lock = RecursiveLock(name: "ReactiveKit.PublishSubject")
private var completed = false
Expand All @@ -77,7 +79,7 @@ public final class PublishSubject<E: EventType>: ObserverRegister<E>, SubjectTyp
}
}

public final class ReplaySubject<E: EventType>: ObserverRegister<E>, SubjectType {
public final class ReplaySubject<E: EventType>: ObserverRegister<E>, RawSubjectType {

public let bufferSize: Int
private var buffer: ArraySlice<E> = []
Expand Down Expand Up @@ -119,7 +121,7 @@ public final class ReplaySubject<E: EventType>: ObserverRegister<E>, SubjectType
}
}

public final class ReplayOneSubject<E: EventType>: ObserverRegister<E>, SubjectType {
public final class ReplayOneSubject<E: EventType>: ObserverRegister<E>, RawSubjectType {

private var event: E? = nil
private let lock = RecursiveLock(name: "ReactiveKit.ReplayOneSubject")
Expand Down Expand Up @@ -156,11 +158,11 @@ public final class ReplayOneSubject<E: EventType>: ObserverRegister<E>, SubjectT
}
}

public final class AnySubject<E: EventType>: SubjectType {
public final class AnySubject<E: EventType>: RawSubjectType {
private let baseObserve: (E -> Void) -> Disposable
private let baseOn: E -> Void

public init<S: SubjectType where S.Event == E>(base: S) {
public init<S: RawSubjectType where S.Event == E>(base: S) {
baseObserve = base.observe
baseOn = base.on
}
Expand Down

0 comments on commit 3584c0e

Please sign in to comment.