Comments (3)
Hi @beeth0ven , thanks for this proposal. I was thinking how you would be able to test effects/feedbacks?
from rxfeedback.swift.
Hi @eliekarouz, thanks for your interest.
Effects can be tested as before with TestScheduler
:
- create
TestScheduler
- create mocked effects
- create mocked events
- inject mocked effects and events to system
- assert output states
PlayCatch Test
let events = [
"tm" : Event.throwToMachine,
"th" : .throwToHuman,
]
let states = [
"h" : State.humanHasIt,
"m" : .machineHasIt
]
// 1. create `TestScheduler`
let scheduler = TestScheduler(initialClock: 0, resolution: resolution, simulateProcessingDelay: false)
// 2. create mocked effects
let mockedEffects: (PitchRequest) -> Observable<Event> = scheduler.mock(values: events) { _ -> String in
return "----th"
};
// 3. create mocked events
let (
inputEvents,
expectedStates
) = (
scheduler.parseEventsAndTimes(timeline: "------tm------tm------tm-------", values: events).first!,
scheduler.parseEventsAndTimes(timeline: "h-----m---h---m---h---m---h----", values: states).first!
)
// 4. inject mocked effects and events to system
let observableSystem = ObservableSystem.create(
initialState: State.humanHasIt,
reduce: { (state: State, event: Event) -> State in
switch event {
case .throwToMachine:
return .machineHasIt
case .throwToHuman:
return .humanHasIt
}
},
scheduler: scheduler
)
.reacted(request: { $0.machinePitching }, effects: mockedEffects)
let state = observableSystem.system([{ _ in scheduler.createHotObservable(inputEvents).asObservable() }])
let recordedState = scheduler.record(source: state)
scheduler.start()
// 5. assert output states
XCTAssertEqual(recordedState.events, expectedStates)
This example use MarbleTests which can be found in RxExample_iOSTests.
from rxfeedback.swift.
Hi there!
Long time no see, hoping every one is doing well. I missed all of you!
Things get evoluted after this proposal. I'm happy to see swift-composable-architecture use a similar pattern and become popular, that's pretty cool!
Then I tried to evolute this idea, and open source a library called love.dart 😄. Yeah it's written in dart since I developed flutter apps recently.
If you are still interested with this "operator pattern". Feel free to take a look. Feedback 😄 are also welcome!
Thank you!
Best Wishes!
from rxfeedback.swift.
Related Issues (20)
- Please update the examples in the README HOT 2
- Problem building dependencies of the example app. HOT 6
- RxFeedback example PlayCatch not working HOT 1
- Add more example about the new react function
- GithubPaginatedSearch example bug
- RxFeedback functions autocomplete problem HOT 2
- Ambiguous reference to member 'system(initialState:reduce:scheduler:feedback:)'
- The printing is printed only after network request is done.
- How can I fix this warning HOT 1
- RequestLifetimeTracking forwardRequests: Duplicate keys were found in Dictionary HOT 6
- Non-equatable requests in 2.0 HOT 6
- How to test the Event creation?
- [Proposal] React for Void?
- bind(self) { ... } leaks HOT 4
- [Request] Could you port RxFeedback to Combine HOT 2
- Carthage for macOS HOT 1
- New Release Tag HOT 11
- [Xcode 15 RC1 Bag] Names conflict HOT 5
- Cannot call value of non-function type '[Observable<Event>.Type]' HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxfeedback.swift.