different route error : providers are “scoped”. if you insert of porovider inside a route, other routes will not be able to access that provider
provider 와의 관계
type을 기준으로 WidgetTree안에서 객체를 찾는다. 타입이 같은경우 가장 가까운 객체만 접근가능하다 → 단순 State여도 class로 관리하는 이유
What is under the hood of BLOC ? or What is that core thing that manages the state in one place?
STREAMS or REACTIVE approach. In general terms, data will be flowing from the BLOC to the UI or from UI to the BLOC in the form of streams. If you have never heard about streams. Read this Stack Overflow answer.
cubit
bloc
dependency injection
buildContext extension
인스턴스간 소통
BlocProvider.of() fails to find Bloc
bloc가 제공된 동일한 컨텐스트에서는 BLOC가 제공되지 않는다. 해당 컨텍스트의 child context에서 위젯 배치
route
anonymous
materialApp에서는 navigator.push 실행시 현재 페이지의 child로 새로운 페이지를 부여하는 것이 아닌 형제 관계로 생성하기때문에 현재 페이지에 제공되어있는 provider를 공유할 수 없다.
이런경우 push할 페이지 위젯을 blocprovider.value 로 감싸 현재 인스턴스를 공유한다 .
아래와 같이 앱 상단에 routes가 세팅되어있는 경우 공유할 인스턴스를 변수에 저장하여 routes마다 페이지를 provider.value로 감싸서 제공할 수있다. 이경우엔 인스턴스를 수동으로 내려줘야하기때문에 상단위젯을 statefulwidget으로 하여 dispose시에 인스턴스 cancel을 해줘야한다.
named
generated
observing cubits/blocs
cubit state cycle
bloc state cycle
event transformation : incoming event를 처리하는 다양한 방식을 적용
처리 함수를 event transformer라고 한다
event별로 또는 앱의 모든 event에 대해 특정 transformer를 적용할 수 있다.
현재 Bloc(v8.1)의 기본 event 처리방식은 concurrent (v7.0까지는 sequential)
restartable 예시 : pagination - 페이지요청이후 처리전에 다른 페이지요청이들어오면 최근요청을 실행
droppable 예시 : infinity scroll - 스크롤이 한계 height을 넘어 새로운 데이터를 로딩중에 새로운 스크롤 요청이 들어오면 무시
event 별로 transformation을 거는 경우 해당 event bucket에만 적용되고 앱단에는 기본 처리방식 또는 앱단 처리방식이 적용된다.