Comments (2)
Hey, great question! This is really tricky, since the issue isn't with the fallibility as much as it is with Swift's initializer requirements. The problem is that you're (probably?) referring to someBooleanExpression
as a reference to self
from within the closure, which is against Swift's rules.
An easy way around this is to make cancelAction
an implicitly unwrapped optional:
var cancelAction: CocoaAction!
And it should be fine.
Let me know if that works, if I can clarify anything, or if I misunderstood the question. Good luck!
from action.
@philipengberg I think you can also use a lazy variable:
class SomeClass {
lazy var cancelAction: CocoaAction = CocoaAction {
if self.someBooleanExpression {
return failWith(CancelError.UnsavedChanges)
}
return just()
}()
...
}
from action.
Related Issues (20)
- Use of undeclared type 'InputSubject' HOT 1
- Potential Memory Leak HOT 2
- Version 4.0.1 could not be found HOT 1
- Memory leak caused by `bind(to:inputTransform:)` HOT 1
- Problem installing with CocoaPods
- Support RxSwift 5.1.0 HOT 1
- Action.elements does not emit item for a inflight request HOT 1
- Crash when using Carthage-cache and Rx v5.1.1 HOT 3
- Pod version not updated HOT 2
- Fix CI HOT 2
- Building for iOS, but the linked framework 'RxCocoa.framework' was built for macOS. (in target 'Action' from project 'Action') HOT 5
- Combine support
- Retain cycle in bind(to:input:) HOT 5
- RxSwift v6.0.0 question HOT 1
- Retain Cycle CocoaAction HOT 2
- alertController 结合 Alamofire会报错
- UIRefreshControl being displayed before view appears
- Ambiguous use of 'init(enabledIf:workFactory:)'
- auto-release Action in function scope
- v4.2.0 throw error when building code
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 action.