Search code examples
iosobjective-cfunctional-programmingreactive-cocoa

ReactiveCocoa replayLast: + take:1


I came across a code snippet in ReactiveCocoa 2 that uses the combination of replayLast and take:1. Given that replayLast returns one element only, is take:1 redundant?

[[[[ ... ] replayLast] take:1] switchToLatest];

Solution

  • It's not redundant: replayLast will start replaying the last element, but it will continue emitting any subsequent values after the initial one.