Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions MobiusCore/Source/Disposables/EmptyDisposable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright Spotify AB.
// SPDX-License-Identifier: Apache-2.0

import Foundation

/// The `EmptyDisposable` class implements a `Disposable` type for when you don't have anything to dispose of.
public final class EmptyDisposable: MobiusCore.Disposable {

/// Create an `EmptyDisposable`
public init() {}

public func dispose() {
// No-op
}
}
4 changes: 2 additions & 2 deletions MobiusCore/Source/EffectHandlers/EffectRouterDSL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public extension _PartialEffectRouter {
return to { parameters, callback in
fireAndForget(parameters)
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
}

Expand All @@ -47,7 +47,7 @@ public extension _PartialEffectRouter {
callback.send(event)
}
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public struct CompositeEventSourceBuilder<Event> {
public func build() -> AnyEventSource<Event> {
switch eventSources.count {
case 0:
return AnyEventSource { _ in AnonymousDisposable {} }
return AnyEventSource { _ in EmptyDisposable() }
case 1:
return eventSources[0]
default:
Expand Down
2 changes: 1 addition & 1 deletion MobiusCore/Test/EffectHandlers/EffectHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ private func handleEffect(effect: Effect, callback: EffectCallback<Event>) -> Di
callback.send(.eventForEffect1)
}
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
2 changes: 1 addition & 1 deletion MobiusCore/Test/EffectHandlers/EffectRouterDSLTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class EffectRouterDSLTests: QuickSpec {
expect(effect).to(equal(.effect1))
callback.send(.eventForEffect1)
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
.asConnectable
.connect { events.append($0) }
Expand Down
6 changes: 3 additions & 3 deletions MobiusCore/Test/EffectHandlers/EffectRouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class EffectRouterTests: QuickSpec {
.to { _, callback in
callback.send(.eventForEffect2)
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
.asConnectable

Expand All @@ -108,7 +108,7 @@ class EffectRouterTests: QuickSpec {

beforeEach {
let handler = AnyEffectHandler<Effect, Event> { _, _ in
AnonymousDisposable {}
EmptyDisposable()
}
let invalidRouter = EffectRouter<Effect, Event>()
.routeEffects(equalTo: .multipleHandlersForThisEffect).to(handler)
Expand Down Expand Up @@ -152,7 +152,7 @@ class EffectRouterTests: QuickSpec {
.routeEffects(equalTo: .effect2)
.to { _, callback in
callback.end()
return AnonymousDisposable {}
return EmptyDisposable()
}
.asConnectable

Expand Down
2 changes: 1 addition & 1 deletion MobiusCore/Test/NonReentrancyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class NonReentrancyTests: QuickSpec {

let testEffectHandler = AnyEffectHandler<Effect, Event> {
handleEffect($0, $1)
return AnonymousDisposable {}
return EmptyDisposable()
}

let effectConnectable = EffectRouter<Effect, Event>()
Expand Down
2 changes: 1 addition & 1 deletion MobiusExtras/Test/EventSource+ExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class EventSourceExtensionsTests: QuickSpec {
beforeEach {
intEventSource = AnyEventSource { (consumer: @escaping (Int) -> Void) in
subscribedIntConsumer = consumer
return AnonymousDisposable {}
return EmptyDisposable()
}
}

Expand Down
Loading