Skip to content

Commit

Permalink
update tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasMirbt committed Aug 23, 2024
1 parent 3ed67d3 commit 417153c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/src/content/docs/tutorials/flutter-infinite-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ Now every time a `PostEvent` is added, if it is a `PostFetched` event and there

The API will return an empty array if we try to fetch beyond the maximum number of posts (100), so if we get back an empty array, our bloc will `emit` the currentState except we will set `hasReachedMax` to true.

If we cannot retrieve the posts, we throw an exception and `emit` `PostFailure()`.
If we cannot retrieve the posts, we emit `PostStatus.failure`.

If we can retrieve the posts, we return `PostSuccess()` which takes the entire list of posts.
If we can retrieve the posts, we emit `PostStatus.success` and the entire list of posts.

One optimization we can make is to `debounce` the `Events` in order to prevent spamming our API unnecessarily. We can do this by overriding the `transform` method in our `PostBloc`.
One optimization we can make is to `throttle` the `PostFetched` event in order to prevent spamming our API unnecessarily. We can do this by using the `transform` parameter when we register the `_onPostFetched` event handler.

:::note
Passing a `transformer` to `on<PostFetched>` allows us to customize how events are processed.
Expand Down

0 comments on commit 417153c

Please sign in to comment.