├── Sources
├── Entwine
│ ├── Common
│ │ ├── Utilities
│ │ │ └── SinkQueue.swift
│ │ └── DataStructures
│ │ │ ├── PriorityQueue.swift
│ │ │ ├── LinkedListQueue.swift
│ │ │ └── LinkedListStack.swift
│ ├── Deprecated
│ │ ├── Deprecations.swift
│ │ └── CancellableBag.swift
│ ├── Utilities
│ │ └── DeallocToken.swift
│ ├── Operators
│ │ ├── ShareReplay.swift
│ │ ├── ReferenceCounted.swift
│ │ ├── Materialize.swift
│ │ ├── ReplaySubject.swift
│ │ ├── WithLatestFrom.swift
│ │ └── Signpost.swift
│ ├── Schedulers
│ │ └── TrampolineScheduler.swift
│ ├── Signal.swift
│ └── Publishers
│ │ └── Factory.swift
├── EntwineTest
│ ├── Common
│ │ ├── Utilities
│ │ │ └── SinkQueue.swift
│ │ └── DataStructures
│ │ │ ├── PriorityQueue.swift
│ │ │ ├── LinkedListQueue.swift
│ │ │ └── LinkedListStack.swift
│ ├── Deprecations.swift
│ ├── Signal+CustomDebugStringConvertible.swift
│ ├── TestEvent.swift
│ ├── TestScheduler
│ │ ├── VirtualTime.swift
│ │ ├── VirtualTimeInterval.swift
│ │ └── TestScheduler.swift
│ ├── TestablePublisher
│ │ └── TestablePublisher.swift
│ ├── TestSequence.swift
│ └── TestableSubscriber
│ │ ├── DemandLedger.swift
│ │ └── TestableSubscriber.swift
└── Common
│ ├── DataStructures
│ ├── LinkedListQueue.swift
│ ├── LinkedListStack.swift
│ └── PriorityQueue.swift
│ └── Utilities
│ └── SinkQueue.swift
├── Makefile
├── .swiftpm
└── xcode
│ ├── package.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ │ ├── IDEWorkspaceChecks.plist
│ │ └── IDETemplateMacros.plist
│ └── xcshareddata
│ └── xcschemes
│ ├── Entwine.xcscheme
│ ├── EntwineTest.xcscheme
│ └── Entwine-Package.xcscheme
├── Tests
├── EntwineTestTests
│ ├── XCTestManifests.swift
│ └── TestablePublisherTests.swift
└── EntwineTests
│ ├── MaterializeTests.swift
│ ├── DematerializeTests.swift
│ ├── FactoryTests.swift
│ ├── TrampolineSchedulerTests.swift
│ ├── ReferenceCountedTests.swift
│ ├── WithLatestFromTests.swift
│ └── ShareReplayTests.swift
├── .github
└── workflows
│ ├── docs.yml
│ ├── ci.yml
│ └── ci.awk
├── Package.swift
├── LICENSE
├── .gitignore
├── Assets
├── Entwine
│ └── README.md
└── EntwineTest
│ └── README.md
└── README.md
/Sources/Entwine/Common/Utilities/SinkQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/Utilities/SinkQueue.swift
--------------------------------------------------------------------------------
/Sources/EntwineTest/Common/Utilities/SinkQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/Utilities/SinkQueue.swift
--------------------------------------------------------------------------------
/Sources/Entwine/Common/DataStructures/PriorityQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/PriorityQueue.swift
--------------------------------------------------------------------------------
/Sources/Entwine/Common/DataStructures/LinkedListQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/LinkedListQueue.swift
--------------------------------------------------------------------------------
/Sources/Entwine/Common/DataStructures/LinkedListStack.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/LinkedListStack.swift
--------------------------------------------------------------------------------
/Sources/EntwineTest/Common/DataStructures/PriorityQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/PriorityQueue.swift
--------------------------------------------------------------------------------
/Sources/EntwineTest/Common/DataStructures/LinkedListQueue.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/LinkedListQueue.swift
--------------------------------------------------------------------------------
/Sources/EntwineTest/Common/DataStructures/LinkedListStack.swift:
--------------------------------------------------------------------------------
1 | ../../../Common/DataStructures/LinkedListStack.swift
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | build:
2 | swift build -c release
3 |
4 | test:
5 | swift test \
6 | --enable-test-discovery \
7 | --parallel
8 |
9 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Tests/EntwineTestTests/XCTestManifests.swift:
--------------------------------------------------------------------------------
1 | import XCTest
2 |
3 | #if !canImport(ObjectiveC) && canImport(Combine)
4 | public func allTests() -> [XCTestCaseEntry] {
5 | return [
6 | testCase(TestSchedulerTests.allTests),
7 | testCase(TestablePublisherTests.allTests),
8 | testCase(TestableSubscriberTests.allTests),
9 | ]
10 | }
11 | #endif
12 |
--------------------------------------------------------------------------------
/.github/workflows/docs.yml:
--------------------------------------------------------------------------------
1 | name: Docs
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 |
7 | jobs:
8 | publish-docs:
9 | name: Publish Docs
10 | runs-on: macos-latest
11 |
12 | steps:
13 | - name: Set up Environment
14 | run: |
15 | git config --global user.email "action@github.com"
16 | git config --global user.name "GitHub Action"
17 | gem install bundler
18 | gem install jazzy --no-document
19 |
20 | - name: Checkout
21 | uses: actions/checkout@v2
22 | with:
23 | ref: 'gh-pages'
24 |
25 | - name: Build Docs
26 | run: make update-docs -C ${{ github.workspace }}
27 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches: [ master ]
6 | pull_request:
7 | branches: [ '*' ]
8 |
9 | jobs:
10 | test:
11 | name: Test
12 | runs-on: macos-latest
13 |
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v2
17 |
18 | - name: Build
19 | run: |
20 | make build -C ${{ github.workspace }} 2>&1 \
21 | | ${{ github.workspace }}/.github/workflows/ci.awk \
22 | -v prefix=${{ github.workspace }} -v fails_on_warning=1
23 |
24 | - name: Run Tests
25 | run: |
26 | make test -C ${{ github.workspace }} 2>&1 \
27 | | ${{ github.workspace }}/.github/workflows/ci.awk \
28 | -v prefix=${{ github.workspace }} -v fails_on_warning=1
29 |
30 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.1
2 | // The swift-tools-version declares the minimum version of Swift required to build this package.
3 |
4 | import PackageDescription
5 |
6 | let package = Package(
7 | name: "Entwine",
8 | platforms: [
9 | .macOS(.v10_12), .iOS(.v10), .tvOS(.v10), .watchOS(.v3)
10 | ],
11 | products: [
12 | .library(
13 | name: "Entwine",
14 | targets: ["Entwine"]),
15 | .library(
16 | name: "EntwineTest",
17 | targets: ["EntwineTest"]),
18 | ],
19 | targets: [
20 | .target(
21 | name: "Entwine",
22 | dependencies: []),
23 | .target(
24 | name: "EntwineTest",
25 | dependencies: ["Entwine"]),
26 | .testTarget(
27 | name: "EntwineTests",
28 | dependencies: ["Entwine", "EntwineTest"]),
29 | .testTarget(
30 | name: "EntwineTestTests",
31 | dependencies: ["EntwineTest"]),
32 | ]
33 | )
34 |
--------------------------------------------------------------------------------
/.github/workflows/ci.awk:
--------------------------------------------------------------------------------
1 | #!/usr/bin/awk -f
2 | BEGIN { FS=":"; errCode=0; mask=fails_on_warning==1?"(error|warning)":"error"; }
3 | {
4 | print;
5 | if(match($0,"^.+:[0-9]+:[0-9]+:[ ]*"mask":[ ]*")) {
6 | message=substr($0,RSTART+RLENGTH); file=$1; gsub("^"prefix"/","",file);
7 | printf("::error file=%s,line=%s,col=%s::%s\n", file, $2, $3, message);
8 | errCode=1;
9 | } else if(match($0,"^.+:[0-9]+:[ ]*"mask":[ ]*")) {
10 | message=substr($0,RSTART+RLENGTH); file=$1; gsub("^"prefix"/","",file);
11 | printf("::error file=%s,line=%s::%s\n", file, $2, message);
12 | errCode=1;
13 | } else if(match($0,/^.+:[0-9]+:[ ]*\*\*\*[ ]*/)) {
14 | message=substr($0,RSTART+RLENGTH); file=$1; gsub("^"prefix"/","",file);
15 | printf("::error file=%s,line=%s::%s\n", file, $2, message);
16 | errCode=1;
17 | } else if(match($0,/^make:[ ]*\*\*\*[ ]*/)) {
18 | message=substr($0,RSTART+RLENGTH); file=$1; gsub("^"prefix"/","",file);
19 | printf("::error ::%s\n", message);
20 | errCode=1;
21 | }
22 | }
23 | END { exit errCode; }
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright © 2019 Tristan Celder. All rights reserved.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/xcshareddata/IDETemplateMacros.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | FILEHEADER
6 |
7 | // Entwine
8 | // https://github.com/tcldr/Entwine
9 | //
10 | // Copyright © 2020 Tristan Celder. All rights reserved.
11 | //
12 | // Permission is hereby granted, free of charge, to any person obtaining a copy
13 | // of this software and associated documentation files (the "Software"), to
14 | // deal in the Software without restriction, including without limitation the
15 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 | // sell copies of the Software, and to permit persons to whom the Software is
17 | // furnished to do so, subject to the following conditions:
18 | //
19 | // The above copyright notice and this permission notice shall be included in
20 | // all copies or substantial portions of the Software.
21 | //
22 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 | // IN THE SOFTWARE.
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/Sources/Entwine/Deprecated/Deprecations.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | import Combine
28 |
29 | @available(*, deprecated, message: "Replace with mutable Set")
30 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
31 | public typealias CancellationBag = Set
32 |
33 | #endif
34 |
--------------------------------------------------------------------------------
/Sources/EntwineTest/Deprecations.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
28 | public extension TestableSubscriber {
29 |
30 | @available(*, deprecated, renamed: "recordedOutput")
31 | var sequence: TestSequence{ recordedOutput }
32 |
33 | @available(*, deprecated, renamed: "recordedDemandLog")
34 | var demands: DemandLedger{ recordedDemandLog }
35 | }
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/Sources/EntwineTest/Signal+CustomDebugStringConvertible.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | import Entwine
28 |
29 | // MARK: - CustomDebugStringConvertible conformance
30 |
31 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
32 | extension Signal: CustomDebugStringConvertible {
33 | public var debugDescription: String {
34 | switch self {
35 | case .subscription:
36 | return ".subscribe"
37 | case .input(let input):
38 | return ".input(\(input))"
39 | case .completion(let completion):
40 | return ".completion(\(completion))"
41 | }
42 | }
43 | }
44 |
45 | #endif
46 |
--------------------------------------------------------------------------------
/Sources/Entwine/Utilities/DeallocToken.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | import Combine
28 |
29 | /// An object that notifies of its deallocation via a publisher sequence
30 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
31 | public final class DeallocToken {
32 |
33 | private let subject = PassthroughSubject<(), Never>()
34 |
35 | /// A publisher that, upon deallocation of the token, publishes a single element and then immediately completes.
36 | public var publisher: AnyPublisher<(), Never> { subject.eraseToAnyPublisher() }
37 |
38 | public init() {}
39 |
40 | deinit {
41 | subject.send()
42 | subject.send(completion: .finished)
43 | }
44 | }
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xccheckout
23 | *.xcscmblueprint
24 |
25 | ## Obj-C/Swift specific
26 | *.hmap
27 | *.ipa
28 | *.dSYM.zip
29 | *.dSYM
30 |
31 | ## Playgrounds
32 | timeline.xctimeline
33 | playground.xcworkspace
34 |
35 | # Swift Package Manager
36 | #
37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
38 | # Packages/
39 | # Package.pins
40 | # Package.resolved
41 | .build/
42 |
43 | # CocoaPods
44 | #
45 | # We recommend against adding the Pods directory to your .gitignore. However
46 | # you should judge for yourself, the pros and cons are mentioned at:
47 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
48 | #
49 | # Pods/
50 | #
51 | # Add this line if you want to avoid checking in source code from the Xcode workspace
52 | # *.xcworkspace
53 |
54 | # Carthage
55 | #
56 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
57 | # Carthage/Checkouts
58 |
59 | Carthage/Build
60 |
61 | # Accio dependency management
62 | Dependencies/
63 | .accio/
64 |
65 | # fastlane
66 | #
67 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
68 | # screenshots whenever they are needed.
69 | # For more information about the recommended setup visit:
70 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
71 |
72 | fastlane/report.xml
73 | fastlane/Preview.html
74 | fastlane/screenshots/**/*.png
75 | fastlane/test_output
76 |
77 | # Code Injection
78 | #
79 | # After new code Injection tools there's a generated folder /iOSInjectionProject
80 | # https://github.com/johnno1962/injectionforxcode
81 |
82 | iOSInjectionProject/
--------------------------------------------------------------------------------
/Sources/EntwineTest/TestEvent.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | import Combine
28 | import Entwine
29 |
30 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
31 | struct TestEvent {
32 |
33 | let time: VirtualTime
34 | let signal: Signal
35 |
36 | init(_ time: VirtualTime, _ signal: Signal) {
37 | self.time = time
38 | self.signal = signal
39 | }
40 | }
41 |
42 | // MARK: - Equatable conformance
43 |
44 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
45 | extension TestEvent: Equatable where Signal: Equatable {}
46 |
47 | // MARK: - CustomDebugStringConvertible conformance
48 |
49 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
50 | extension TestEvent: CustomDebugStringConvertible {
51 | public var debugDescription: String {
52 | return "SignalEvent(\(time), \(signal))"
53 | }
54 | }
55 |
56 | #endif
57 |
--------------------------------------------------------------------------------
/Sources/Entwine/Operators/ShareReplay.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Entwine
3 | // https://github.com/tcldr/Entwine
4 | //
5 | // Copyright © 2019 Tristan Celder. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #if canImport(Combine)
26 |
27 | import Combine
28 |
29 | @available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
30 | extension Publisher {
31 | /// Returns a publisher as a class instance that replays previous values to new subscribers
32 | ///
33 | /// The downstream subscriber receives elements and completion states unchanged from the
34 | /// previous subscriber, and in addition replays the latest elements received from the upstream
35 | /// subscriber to any new subscribers. Use this operator when you want new subscribers to
36 | /// receive the most recently produced values immediately upon subscription.
37 | ///
38 | /// - Parameter maxBufferSize: The number of elements that should be buffered for
39 | /// replay to new subscribers
40 | /// - Returns: A class instance that republishes its upstream publisher and maintains a
41 | /// buffer of its latest values for replay to new subscribers
42 | public func share(replay maxBufferSize: Int) -> Publishers.ReferenceCounted> {
43 | multicast { ReplaySubject