Skip to content

Commit

Permalink
fix(binding): fix type in persist handler - it may return next handle…
Browse files Browse the repository at this point in the history
…r without promise
  • Loading branch information
matej21 committed Dec 27, 2023
1 parent 0cbcf50 commit cddd184
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build/api/binding.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export namespace EntityAccessor {
// (undocumented)
export type BatchUpdatesHandler = (getAccessor: GetEntityAccessor, options: BatchUpdatesOptions) => void;
// (undocumented)
export type BeforePersistHandler = (getAccessor: GetEntityAccessor, options: AsyncBatchUpdatesOptions) => void | Promise<void | BeforePersistHandler>;
export type BeforePersistHandler = (getAccessor: GetEntityAccessor, options: AsyncBatchUpdatesOptions) => void | BeforePersistHandler | Promise<void | BeforePersistHandler>;
// (undocumented)
export interface EntityEventListenerMap extends RuntimeEntityEventListenerMap {
// (undocumented)
Expand All @@ -233,7 +233,7 @@ export namespace EntityAccessor {
// (undocumented)
export type PersistErrorHandler = (getAccessor: GetEntityAccessor, options: PersistErrorOptions) => void | Promise<void>;
// (undocumented)
export type PersistSuccessHandler = (getAccessor: GetEntityAccessor, options: PersistSuccessOptions) => void | Promise<void | PersistSuccessHandler>;
export type PersistSuccessHandler = (getAccessor: GetEntityAccessor, options: PersistSuccessOptions) => void | PersistSuccessHandler | Promise<void | PersistSuccessHandler>;
// (undocumented)
export interface RuntimeEntityEventListenerMap {
// (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions packages/binding/src/accessors/EntityAccessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ namespace EntityAccessor {
export type BeforePersistHandler = (
getAccessor: GetEntityAccessor,
options: AsyncBatchUpdatesOptions,
) => void | Promise<void | BeforePersistHandler>
) => void | BeforePersistHandler | Promise<void | BeforePersistHandler>

export type PersistErrorHandler = (
getAccessor: GetEntityAccessor,
Expand All @@ -272,7 +272,7 @@ namespace EntityAccessor {
export type PersistSuccessHandler = (
getAccessor: GetEntityAccessor,
options: PersistSuccessOptions,
) => void | Promise<void | PersistSuccessHandler>
) => void | PersistSuccessHandler | Promise<void | PersistSuccessHandler>

export interface RuntimeEntityEventListenerMap {
beforePersist: BeforePersistHandler
Expand Down
3 changes: 2 additions & 1 deletion packages/binding/src/treeParameters/EventListenersStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type AnyFunction = (...args: any[]) => any
type GenericEventsMap<EventTypes extends string> = {
[K in EventTypes]?: (...args: any[]) => void | Promise<void | any>
[K in EventTypes]?: (...args: any[]) => void | AnyFunction | Promise<void | AnyFunction>
}

export class EventListenersStore<EventTypes extends string, Events extends GenericEventsMap<EventTypes>> {
Expand Down

0 comments on commit cddd184

Please sign in to comment.