-
Notifications
You must be signed in to change notification settings - Fork 72
10월 모바일팀 이학림 블로그 PR #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10월 모바일팀 이학림 블로그 PR #234
Conversation
| } | ||
| ``` | ||
|
|
||
| 일반적으로 `Stream` 객체의 데이터에 접근하는 과정에서 iterator의 개념이 사용되는데, 가장 최근에 올라온 이벤트들을 하나씩 처리하고 지워나가면서 `Stream` 안에 남은이벤트가 없어질 때 까지 이를 계속하게 된다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
남은이벤트 -> 남은 이벤트 수정 부탁드립니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵
| } | ||
| ``` | ||
| `Stream`으로 정의된 함수는 선언 즉시 `Stream` 객체를 반환하며, 그 후엔 `Stream`의 데이터에 접근해 사용할 때까지 아무 일도 일어나지 않는다. | ||
| 이후 <strong>`listen()`</strong>/<strong>`await for`</strong> 키워드를 통해 `Stream`객체의 데이터에 접근할 수 있으며, 이 때 `async*` 함수가 동작하게 된다. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async* 함수에서 *는 의도된 표현인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네! dart에서 async/async* future/stream 타입 종류에 따라구분되어 사용되고 있습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
블로그글 내용 수정해서 명시하겠습니다
|
데일리 스크럼 시간에 동기/비동기 이야기를 좀 나눴었는데, 글로도 남겨주셔서 감사하고 예시를 들어주시니 이해가 더 쉽게 되네요! |
| <br> | ||
|
|
||
| 이 때, `snapshot.hasData`라는 필드에 접근해서 비동기처리의 상태를 알아낼 수 있다. | ||
| `true` => 외부로부터 결과값 or Error값을 받아온 상태 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사소하지만 true와 false 부분을 줄바꿈으로 가독성을 높이는 건 어떠실까요?
보기에도 더 예쁠거 같습니다 ㅎㅎ !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 감사합니다
| void main() async{ | ||
|
|
||
| Future<String> getString1(){ | ||
| return Future.delayed(Duration(seconds:1),()=>"연산1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future 타입은 반환할 때 Future<String>으로 명시를 해주지 않아도 상관없나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future을 명시해주지 않아도 var 타입처럼 런타임중 자동으로 타입이 결정되어 실행되는 것 같습니다(var과 매커니즘이 똑같은지는 잘 모르겠습니다). 하지만 Future가 복잡하게 사용되는 상황에서 Future을 명시해주지 않으면 원하지 않는 타입을 반환해서 오류가 발생하는 일이 있을 수 있습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 aysnc 함수의 반환형을 물으신 거라면.. 명시해주지 않아도 됩니다. 정확히는 async 키워드는함수의 body내에서 future형을 다룬다는 것을 의미하므로 async 함수자체의 반환형이 future일 필요는 없습니다. 이 내용도 추가하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전자의 상황이었지만 var처럼 사용된다니 역시 좋은 언어인거 같습니다 ㅎㅎ
|
Future 타입만 다뤄보았는데 Stream도 이해할 수 있어서 좋았습니다 ㅎㅎ 정리를 잘해주셔서 종종 까먹을 때 와서 보기 좋아요! |
|
1,2,3 수정해봤습니다~! |
markdown 문법 오류 수정
No description provided.