Comments (7)
The objection to this approach is that it keeps objects alive.
from reactiveobjc.
Are you thinking about the caching?
- (instancetype)setNameBlock:(NSString *(^)(void))nameBlock
{
__block NSString *cache;
_nameBlock = [^NSString *{
if(cache == nil)
{
cache = nameBlock();
}
return cache;
} copy];
return self;
}
Caching can be omitted.
from reactiveobjc.
foo
is kept alive in your example:
- (void)testWithSignal
{
Foo *foo = [Foo new];
RACSignal *signal = [[RACSignal new] someOperatorWithObject:foo];
XCTAssertTrue(foo.descriptionRequestedCount == 0, @"");
XCTAssertEqualObjects([signal name], @"transformed using `someOperatorWithObject` with object <Foo 0xFOOBAR>");
XCTAssertTrue(foo.descriptionRequestedCount == 1, @"");
XCTAssertEqualObjects([signal name], @"transformed using `someOperatorWithObject` with object <Foo 0xFOOBAR>");
XCTAssertTrue(foo.descriptionRequestedCount == 1, @"");
}
from reactiveobjc.
You're right. That means the convenience macro is not a good idea as each object would need to weakly captured.
And my feeling is that this is probably too cumbersome
- (instancetype)someOperatorWithObject:(NSObject *)object
{
@weakify(object);
return [self setNameBlock:^NSString *{
@strongify(object);
return [NSString stringWithFormat:@"transformed using `someOperatorWithObject` with object %@", [object description]];
}];
}
from reactiveobjc.
You could probably build the @weakify
/@strongify
into a macro that sets the name. Feel free to open a PR if you'd like to work on that.
from reactiveobjc.
Yeah, I could do a PR if you guys think this is a good idea. Don't want to invest time and then get it rejected if you fundamentally disagree about the concept :)
from reactiveobjc.
No, that seems like an acceptable approach to me.
from reactiveobjc.
Related Issues (20)
- RACObserve(target, key) HOT 1
- should I check the existance of weakself before @strongify(self) ? HOT 3
- [RACCommand addActiveExecutionSignal:]crashed HOT 2
- Error: 'ReactiveObjC/EXTKeyPathCoding.h' file not found๏ผ
- why the instruments say that the RAC Memory leaks?
- Why use pods package tools make static frame error ? .podspec is ok? HOT 1
- OSAtomic deprecation in iOS 10.0 HOT 1
- Xcode12 ReactiveObjC archive error HOT 2
- SMP HAVE NO SUPPORT
- 3.1.1 endless loop
- AVPlayerItem was deallocated while key value observers were still registered with it.
- crash in -[NSObject(RACDeallocating) rac_deallocDisposable] NSObject+RACDeallocating.m
- Delay delays cancelled stream completion
- ้ช้ HOT 1
- m1 Can't install 3.1.1 via CocoaPods
- ReactiveObjC (3.1.1) Build Failed
- Get build errors with Xcode 15 HOT 3
- Xcode 15 Release build error "error: unexpected '@' in program @weakify(self); ^" HOT 2
- iOS 17 Crash
- Apple requires third-party SDKs to contain a privacy manifest file HOT 3
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 reactiveobjc.