Skip to content

Commit

Permalink
fix: adopt breaking changes of updates-svc (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxSchaefer authored Dec 9, 2024
1 parent 58fc60d commit f889be7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion api-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": {
"@helpwave/common": "workspace:*",
"@helpwave/proto-ts": "0.60.0-1191f09.0",
"@helpwave/proto-ts": "0.61.0-e1d7c0c.0",
"@tanstack/react-query": "4.36.1",
"@tanstack/react-query-devtools": "5.59.16",
"@types/google-protobuf": "3.15.12",
Expand Down
22 changes: 10 additions & 12 deletions api-services/util/useUpdates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { PropsWithChildren } from 'react'
import { createContext, useContext, useEffect, useRef, useState } from 'react'
import type { Observable } from 'rxjs'
import { filter, fromEvent, map, startWith, Subject } from 'rxjs'
import type { DomainEvent } from '@helpwave/proto-ts/services/updates_svc/v1/updates_svc_pb'
import { ReceiveUpdatesResponse } from '@helpwave/proto-ts/services/updates_svc/v1/updates_svc_pb'
import ReceiveUpdatesStreamHandler from './ReceiveUpdatesStreamHandler'

// Two types of speed should be enough.
Expand All @@ -28,6 +26,8 @@ if (typeof window !== 'undefined') {
}

type UpdatesSubject = {
eventId: string,
eventType: string,
aggregateType: string,
aggregateId: string
}
Expand Down Expand Up @@ -58,16 +58,14 @@ export const ProvideUpdates = ({ children }: PropsWithChildren) => {
.getInstance()
.observable
.subscribe((res) => {
let domainEvent: DomainEvent

switch (res.getEventCase()) {
case ReceiveUpdatesResponse.EventCase.DOMAIN_EVENT:
domainEvent = res.getDomainEvent()!
updatesSubject.next({
aggregateType: domainEvent.getAggregateType(),
aggregateId: domainEvent.getAggregateId()
})
break
if (res.hasEvent()) {
const event = res.getEvent()!
updatesSubject.next({
eventId: event.getEventId(),
eventType: event.getEventType(),
aggregateType: event.getAggregateType(),
aggregateId: event.getAggregateId()
})
}

// Only set revision when handlers are executed successfully
Expand Down
31 changes: 23 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"@headlessui/react": "1.7.19",
"@helpwave/api-services": "workspace:*",
"@helpwave/common": "workspace:*",
"@helpwave/proto-ts": "0.60.0-1191f09.0",
"@radix-ui/react-checkbox": "1.1.2",
"@tanstack/react-query": "4.36.1",
"@tanstack/react-query-devtools": "5.59.16",
Expand Down

0 comments on commit f889be7

Please sign in to comment.