felangel / bloc

A predictable state management library that helps implement the BLoC design pattern
https://bloclibrary.dev
MIT License
11.76k stars 3.39k forks source link

feat: can we rename copyWith to replaceWith #4192

Closed ysumiit005 closed 3 months ago

ysumiit005 commented 3 months ago

Description

Replace copyWith to replaceWith as it's more easy to understand while reading

copyWith means like my data is copied and 2 instance of things exist

While replaceWith means like my data is replaced with new data similar to setState. replaceWith is more clear

Desired Solution

rename copyWith to replaceWith

Alternatives Considered setState or change notifier is more simple to understand each time I read it. but copyWith always tricks me and lot of developer

Thanks 😊👍

felangel commented 3 months ago

Hi @ysumiit005 👋 Thanks for opening an issue!

Bloc does not explicitly provide a copyWith API, this is just a convention used in the documentation and example. copyWith is used throughout the Dart SDK as well as Flutter so I recommend sticking to the convention but bloc does not have an opinions about how you name your copyWith so you can use replaceWith in your own code if you prefer.

Hope that helps!