Skip to content

Commit

Permalink
fix: ViewModel 컨벤션에 맞게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
taipaise committed Nov 14, 2024
1 parent 444d16e commit d877acf
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ final class WhiteboardViewModel: ViewModel {
}

struct Output {
let whiteboardObjects: CurrentValueSubject<[WhiteboardObject], Never>
let whiteboardObjectsPublisher: AnyPublisher<[WhiteboardObject], Never>
}

let output: Output
private let drawObjectUseCase: DrawObjectUseCaseInterface
private let output: Output
private var whiteboardObjects = CurrentValueSubject<[WhiteboardObject], Never>([])

init(drawObjectUseCase: DrawObjectUseCaseInterface) {
self.drawObjectUseCase = drawObjectUseCase

output = Output(whiteboardObjects: CurrentValueSubject<[WhiteboardObject], Never>([]))
output = Output(whiteboardObjectsPublisher: whiteboardObjects.eraseToAnyPublisher())
}

func action(input: Input) {
Expand All @@ -50,8 +51,8 @@ final class WhiteboardViewModel: ViewModel {

private func finishDrawing() {
guard let drawingObject = drawObjectUseCase.finishDrawing() else { return }
var newObjects = output.whiteboardObjects.value
var newObjects = whiteboardObjects.value
newObjects.append(drawingObject)
output.whiteboardObjects.send(newObjects)
whiteboardObjects.send(newObjects)
}
}

0 comments on commit d877acf

Please sign in to comment.