-
Notifications
You must be signed in to change notification settings - Fork 2
[Feat] 자동로그인 Reactorkit - pulse 도입 #409
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e065356
feat/# pulse class 구현
hooni0918 a46cb88
feat/#408 pulse 로직 채택
hooni0918 46399bb
feat/#408 Add navigation pulse handling and emit based on login response
hooni0918 87dcad9
feat/#408 불필요주석제거
hooni0918 5fe8503
refactor/#408 재동작 코드 수정
hooni0918 56946dd
feat/#408 pulse 설명문 추가
hooni0918 0e097f1
feat:#408 회원탈퇴로직 정상화
hooni0918 1f98897
feat/#408 Improve error handling
hooni0918 a4586d0
feat/#408 오류해결
hooni0918 57a1118
Merge branch 'suyeon' into feat/#408-imageChesingDevelop
hooni0918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // | ||
| // Pulse.swift | ||
| // KkuMulKum | ||
| // | ||
| // Created by 이지훈 on 2/24/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// 일회성 이벤트를 관리하기 위한 제네릭 클래스 | ||
| /// Pulse는 이벤트를 한 번만 전달하고, 이후 추가 구독자에게는 마지막 이벤트를 즉시 전달하는 메커니즘을 제공합니다. | ||
| class Pulse<T> { | ||
| /// 리스너 타입 정의 (이벤트 핸들러) | ||
| typealias Listener = (T) -> Void | ||
|
|
||
| /// 현재 저장된 값 | ||
| private var value: T? | ||
|
|
||
| /// 등록된 리스너 목록 | ||
| private var listeners: [Listener] = [] | ||
|
|
||
| /// 이벤트가 이미 소비되었는지 추적하는 플래그 | ||
| private var isConsumed = false | ||
|
|
||
| /// 새로운 Pulse 인스턴스 생성 | ||
| init() {} | ||
|
|
||
| /// 이벤트 값을 전달하고 모든 리스너에게 알림 | ||
| /// - Parameter value: 전달할 이벤트 값 | ||
| /// - Note: 이벤트는 한 번만 전달되며, 이후 추가 emit은 무시됨 | ||
| func emit(_ value: T) { | ||
| guard !isConsumed else { return } | ||
|
|
||
| self.value = value | ||
| isConsumed = true | ||
|
|
||
| // 모든 리스너에게 값 전달 | ||
| listeners.forEach { $0(value) } | ||
|
|
||
| // 발신 후 리스너 비우기 | ||
| listeners.removeAll() | ||
| } | ||
|
|
||
| /// 리스너를 등록하고 이미 발행된 이벤트가 있다면 즉시 전달 | ||
| /// - Parameter listener: 이벤트를 처리할 클로저 | ||
| func subscribe(_ listener: @escaping Listener) { | ||
| if let value = value, isConsumed { | ||
| // 이미 값이 발신되었다면 즉시 전달 | ||
| listener(value) | ||
| } else { | ||
| // 아직 값이 없다면 리스너 등록 | ||
| listeners.append(listener) | ||
| } | ||
| } | ||
|
|
||
| /// 약한 참조로 리스너를 등록하고 이미 발행된 이벤트가 있다면 즉시 전달 | ||
| /// - Parameters: | ||
| /// - object: 리스너가 속한 약한 참조 객체 | ||
| /// - listener: 이벤트를 처리할 클로저 (객체와 값을 받음) | ||
| func subscribe<O: AnyObject>(with object: O, listener: @escaping (O, T) -> Void) { | ||
| let wrappedListener: Listener = { [weak object] value in | ||
| guard let object = object else { return } | ||
| listener(object, value) | ||
| } | ||
|
|
||
| if let value = value, isConsumed { | ||
| // 이미 값이 발신되었다면 즉시 전달 | ||
| wrappedListener(value) | ||
| } else { | ||
| // 아직 값이 없다면 리스너 등록 | ||
| listeners.append(wrappedListener) | ||
| } | ||
| } | ||
|
|
||
| /// 모든 상태를 초기화하여 Pulse를 재사용 가능한 상태로 만듦 | ||
| func reset() { | ||
| value = nil | ||
| isConsumed = false | ||
| listeners.removeAll() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
어이구 이거 왜 이렇게 됐지요