-
Notifications
You must be signed in to change notification settings - Fork 47
Combine Worker #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Combine Worker #104
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
de75910
Create WorkflowCombine library
soorinpark decc7c0
Create Worker backed with Combine Publisher
soorinpark b06a710
Add Testing modules and podspec
soorinpark 41a3c57
Completed same test suite as the WorkflowReactiveSwift library
soorinpark 262c8da
Add missing Publisher tests
soorinpark c647ee7
Create a sample app for Combine backed worker
soorinpark 9f0b8fc
Fixed testPublisherWorkflow's TestWorkflow implmentation
soorinpark c00fecc
Remove WorkflowCombineTestingTests target from podspec
soorinpark f7a096b
Add tests to WorkflowCombineSampleApp
soorinpark ecf518d
Add README for WorkflowCombineSampleApp
soorinpark 525a936
Create WorkflowCombineSampleApp through podspec instead
soorinpark 55db045
handle cancelling cancellable on lifetime ending
soorinpark d54c04d
Remove references of WorkflowReactiveSwift from WorkflowCombineSampleApp
soorinpark 2057460
Removed unwanted files
soorinpark 2b727df
Fix Workflows to take a generic publisher type
soorinpark 07fd80a
Remove the need to type-erase publisher to render the workflow view
soorinpark c4d4d10
Separate WorkflowCombineTesting module
soorinpark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,18 @@ | ||
project 'WorkflowCombineSampleApp.xcodeproj' | ||
platform :ios, '13.0' | ||
|
||
target 'WorkflowCombineSampleApp' do | ||
pod 'Workflow', path: '../../Workflow.podspec', :testspecs => ['Tests'] | ||
pod 'WorkflowUI', path: '../../WorkflowUI.podspec', :testspecs => ['Tests'] | ||
pod 'WorkflowCombine', path: '../../WorkflowCombine.podspec' | ||
pod 'WorkflowReactiveSwift', path: '../../WorkflowReactiveSwift.podspec', :testspecs => ['Tests'] | ||
|
||
target 'WorkflowCombineSampleAppUnitTests' do | ||
inherit! :search_paths | ||
|
||
pod 'Workflow', path: '../../Workflow.podspec', :testspecs => ['Tests'] | ||
pod 'WorkflowCombine', path: '../../WorkflowCombine.podspec' | ||
pod 'WorkflowReactiveSwift', path: '../../WorkflowReactiveSwift.podspec', :testspecs => ['Tests'] | ||
pod 'WorkflowUI', path: '../../WorkflowUI.podspec', :testspecs => ['Tests'] | ||
end | ||
end |
This file contains hidden or 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 @@ | ||
PODS: | ||
- ReactiveSwift (6.3.0) | ||
- Workflow (1.0.0-rc.1): | ||
- ReactiveSwift (~> 6.3.0) | ||
- Workflow/Tests (1.0.0-rc.1): | ||
- ReactiveSwift (~> 6.3.0) | ||
- WorkflowCombine (1.0.0-rc.1): | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowReactiveSwift (1.0.0-rc.1): | ||
- ReactiveSwift (~> 6.3.0) | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowReactiveSwift/Tests (1.0.0-rc.1): | ||
- ReactiveSwift (~> 6.3.0) | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowTesting (= 1.0.0-rc.1) | ||
- WorkflowTesting (1.0.0-rc.1): | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowUI (1.0.0-rc.1): | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowUI/Tests (1.0.0-rc.1): | ||
- Workflow (= 1.0.0-rc.1) | ||
- WorkflowReactiveSwift (= 1.0.0-rc.1) | ||
|
||
DEPENDENCIES: | ||
- Workflow (from `../../Workflow.podspec`) | ||
- Workflow/Tests (from `../../Workflow.podspec`) | ||
- WorkflowCombine (from `../../WorkflowCombine.podspec`) | ||
- WorkflowReactiveSwift (from `../../WorkflowReactiveSwift.podspec`) | ||
- WorkflowReactiveSwift/Tests (from `../../WorkflowReactiveSwift.podspec`) | ||
- WorkflowUI (from `../../WorkflowUI.podspec`) | ||
- WorkflowUI/Tests (from `../../WorkflowUI.podspec`) | ||
|
||
SPEC REPOS: | ||
trunk: | ||
- ReactiveSwift | ||
- WorkflowTesting | ||
|
||
EXTERNAL SOURCES: | ||
Workflow: | ||
:path: "../../Workflow.podspec" | ||
WorkflowCombine: | ||
:path: "../../WorkflowCombine.podspec" | ||
WorkflowReactiveSwift: | ||
:path: "../../WorkflowReactiveSwift.podspec" | ||
WorkflowUI: | ||
:path: "../../WorkflowUI.podspec" | ||
|
||
SPEC CHECKSUMS: | ||
ReactiveSwift: 7937f26ec18d555e2a99352bd0a8b2817d1f042d | ||
Workflow: e3391755e611eb0e0efc244ef5fa9b12c6e2f8ab | ||
WorkflowCombine: 8806745d6023261bfbc34e0d1da753774e9fe0c5 | ||
WorkflowReactiveSwift: a1854c330a7ea4342e999156e0abe7f216e16d63 | ||
WorkflowTesting: ff584e427bda8491285deb97db14182925d1e4f4 | ||
WorkflowUI: 0e3b93590dc2e58a93f300a47e5c8e81b501ef36 | ||
|
||
PODFILE CHECKSUM: 0a8cc7b6b118ae7091c5f1104b8d8cbffe43c04f | ||
|
||
COCOAPODS: 1.9.1 |
This file contains hidden or 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,48 @@ | ||
# WorkflowCombineSampleApp | ||
|
||
This sample project utilizes the WorkflowCombine library to demonstrate its usage in a `Workflow`. It is a simple app with a label that updates the current date & time every second. | ||
|
||
# Usage | ||
|
||
Thanks to the `AnyWorkflowConvertible` protocol, both the `WorkflowReactiveSwift` and `WorkflowCombine` Workers have identical api interface. To to migrate your `WorkflowReactiveSwift` `Worker`s to use the `WorkflowCombine` `Worker`s, you will need to do the following: | ||
soorinpark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. Change `import` statements to use `WorkflowCombine` and `Combine` | ||
2. Replace `SignalProducer` into `AnyPublisher` for the return type of `run` | ||
3. Change the `run` implementation to the `Combine` equivalence. Most likely this will be the step that that requires the most attention, however if the tests were written for the `Workflow` it can be used to validate the new implementation without the need to change the tests. | ||
|
||
Below is an example of a simple `Worker` in both `WorkflowReactiveSwift` and `WorkflowCombine` that emits a signal every second with the current date. | ||
|
||
### `WorkflowReactiveSwift` | ||
|
||
```swift | ||
struct TimerWorker: Worker { | ||
typealias Output = Date | ||
|
||
func run() -> SignalProducer<Output, Never> { | ||
SignalProducer | ||
.timer(interval: DispatchTimeInterval.seconds(1), on: QueueScheduler.main) | ||
} | ||
|
||
func isEquivalent(to otherWorker: TimerWorker2) -> Bool { true } | ||
} | ||
``` | ||
|
||
### `WorkflowCombine` | ||
|
||
```swift | ||
struct TimerWorker: Worker { | ||
typealias Output = Date | ||
|
||
func run() -> AnyPublisher<Output, Never> { | ||
Timer.publish(every: 1, on: .main, in: .common) | ||
.autoconnect() | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
func isEquivalent(to otherWorker: Self) -> Bool { true } | ||
} | ||
``` | ||
|
||
### Notes | ||
|
||
This library does **not** remove the usage of the `ReactiveSwift` library from the `Workflow` library. Currently the `Workflow` implementation is tightly coupled with `ReactiveSwift`, and this library is only limited to the `Worker`. Therefore, when utilizing both the existing `Workflow` and the new `Combine` backed `Worker` , you will need to utilize both the `ReactiveSwift` and `Combine` libraries. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.