-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add observable subscription to Publisher
- Loading branch information
Showing
15 changed files
with
482 additions
and
28 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
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
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
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
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
51 changes: 51 additions & 0 deletions
51
DXFeedFramework/Native/Subscription/DXObservableSubscription.swift
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,51 @@ | ||
// | ||
// | ||
// Copyright (C) 2023 Devexperts LLC. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. | ||
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
// | ||
|
||
import Foundation | ||
|
||
class DXObservableSubscription { | ||
/// Subscription native wrapper. | ||
private let native: NativeObservableSubscription | ||
/// List of event types associated with this ``DXObservableSubscription`` | ||
fileprivate let events: Set<EventCode> | ||
/// A set listeners of events | ||
/// | ||
/// | ||
/// - Throws: ``GraalException`` Rethrows exception from Java, ``ArgumentException/argumentNil`` | ||
internal init(native: NativeObservableSubscription?, events: [EventCode]) throws { | ||
if let native = native { | ||
self.native = native | ||
} else { | ||
throw ArgumentException.argumentNil | ||
} | ||
self.events = Set(events) | ||
} | ||
} | ||
|
||
extension DXObservableSubscription: IObservableSubscription { | ||
public func isClosed() -> Bool { | ||
return native.isClosed() | ||
} | ||
|
||
public var eventTypes: Set<EventCode> { | ||
return events | ||
} | ||
|
||
public func isContains(_ eventType: EventCode) -> Bool { | ||
return events.contains(eventType) | ||
} | ||
|
||
/// - Throws: GraalException. Rethrows exception from Java. | ||
public func addChangeListener(_ listener: ObservableSubscriptionChangeListener) throws { | ||
try native.addChangeListener(listener) | ||
} | ||
|
||
/// - Throws: GraalException. Rethrows exception from Java. | ||
public func removeChangeListener(_ listener: ObservableSubscriptionChangeListener) throws { | ||
try native.removeChangeListener(listener) | ||
} | ||
} |
Oops, something went wrong.