Skip to content
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

[refactor] ObservablePattern 다중 구독 구현하기 #387

Merged
merged 2 commits into from
Sep 15, 2024

Conversation

JinUng41
Copy link
Contributor

🔗 연결된 이슈

📄 작업 내용

  • Observable Pattern 이 다중 구독이 가능하도록 수정하였습니다.
  • 여러 상태 값이 공유되어야 하는 유진이를 고려한 수정입니다.

💻 주요 코드 설명

Observable Pattern의 다중 구독

  • 지금의 구현은 단일 구독만 가능하기 때문에, 기존의 구독에서 새로운 구독이 생기면 기존 구독은 덮여씌워집니다.
  • 배열로써, 다중 구독이 가능하도록 하였습니다.
  • 간단하게나마, 동작을 확인하였지만 시간이 남으시다면, 현재 브랜치에서 간단한 QA 부탁드리겠습니다.

@JinUng41 JinUng41 self-assigned this Sep 14, 2024
@JinUng41 JinUng41 added ♻️ refactor 기존 코드를 리팩토링하거나 수정하는 등 사용 (생산적인 경우) 💙 JinUng 걸스 토크에 미쳐보고 싶다면 labels Sep 14, 2024
@JinUng41 JinUng41 linked an issue Sep 14, 2024 that may be closed by this pull request
1 task
Copy link
Member

@youz2me youz2me left a comment

Choose a reason for hiding this comment

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

LGTM 👍

private var listener: ((T) -> Void)?
typealias Listener = (T) -> Void

private var listeners: [Listener] = []
Copy link
Member

Choose a reason for hiding this comment

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

캬...

Comment on lines +25 to +30
private func notifyListeners(_ value: T) {
for listener in listeners {
listener(value)
}
}

Copy link
Member

Choose a reason for hiding this comment

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

더 간편해졌군요!! 감사합니닷 ㅎㅎ

Copy link
Member

@hooni0918 hooni0918 left a comment

Choose a reason for hiding this comment

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

오 이제 사용시에 이전과 동일하게 사용하는거지만 다중구독이 되는걸까요?

@JinUng41
Copy link
Contributor Author

오 이제 사용시에 이전과 동일하게 사용하는거지만 다중구독이 되는걸까요?

네, 그렇습니다.

Copy link
Member

@mmaybei mmaybei left a comment

Choose a reason for hiding this comment

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

이건 생각을 못했었네요 짱입니다👍🏻

@JinUng41 JinUng41 merged commit 913bfcb into suyeon Sep 15, 2024
@JinUng41 JinUng41 deleted the refactor/#386-observablePattern branch September 15, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💙 JinUng 걸스 토크에 미쳐보고 싶다면 ♻️ refactor 기존 코드를 리팩토링하거나 수정하는 등 사용 (생산적인 경우)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[refactor] 다중 구독이 가능한 ObservablePattern
4 participants