Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented Oct 31, 2017

Example

Sequence::of($import)
  ->peek(function($record) { Console::write($record['name']); })
  ->map(function($record) {
    $existing= $this->database->lookup($record['name']);
    return $this->database->replace($existing, $record);
  })
  ->catch(function($e) { $e->printStackTrace(); })
  ->peek(function($id) { Console::writeLine(' -> #', $id); )
  ->each()
;

BC break

⚠️ Sequence::$EMPTY needs to b rewritten as Sequence::empty().

Performance

This pull request introduces wide-ranging implementation changes, which also have a slight performance hit:

# [feature/catch]
$ xp -m ../measure/ measure -n 1000 Operations
counting: 1000 iteration(s), 1.159 seconds, result= 10000
collecting: 1000 iteration(s), 2.067 seconds, result= 10000

# [master]
$ xp -m ../measure/ measure -n 1000 Operations
counting: 1000 iteration(s), 1.013 seconds, result= 10000
collecting: 1000 iteration(s), 1.857 seconds, result= 10000

See also http://reactivex.io/documentation/operators/catch.html and #30

} catch (\Throwable $t) {
$this->error= $t;
} catch (\Exception $e) {
$this->error= $e;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think about wrapping this in a lang.Throwabe.

@thekid
Copy link
Member Author

thekid commented Sep 30, 2019

#30 seems to cover more usecases

@thekid thekid closed this Sep 30, 2019
@thekid thekid deleted the feature/catch branch September 30, 2019 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants