@effect-app/vue 2.85.0 → 2.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/makeClient.ts CHANGED
@@ -1515,21 +1515,15 @@ export type ToCamel<S extends string | number | symbol> = S extends string
1515
1515
  : Uncapitalize<S>
1516
1516
  : never
1517
1517
 
1518
- export interface CommandBase<I extends ReadonlyArray<any>, A = void> {
1519
- handle: (...input: I) => A
1518
+ export interface CommandBase<I = void, A = void> {
1519
+ handle: (input: I) => A
1520
1520
  waiting: boolean
1521
1521
  action: string
1522
1522
  label: string
1523
1523
  }
1524
1524
 
1525
- // export interface Command<I extends ReadonlyArray<any>> extends CommandBase<I, void> {}
1526
-
1527
- export interface EffectCommand<I extends ReadonlyArray<any>, A = unknown, E = unknown>
1528
- extends CommandBase<I, RuntimeFiber<A, E>>
1529
- {}
1530
-
1531
- export interface UnaryCommand<I, A = unknown, E = unknown> extends CommandBase<[I], RuntimeFiber<A, E>> {}
1525
+ export interface EffectCommand<I = void, A = unknown, E = unknown> extends CommandBase<I, RuntimeFiber<A, E>> {}
1532
1526
 
1533
1527
  export interface CommandFromRequest<I extends abstract new(...args: any) => any, A = unknown, E = unknown>
1534
- extends UnaryCommand<ConstructorParameters<I>[0], A, E>
1528
+ extends EffectCommand<ConstructorParameters<I>[0], A, E>
1535
1529
  {}
@@ -24,10 +24,10 @@ describe("alt2", () => {
24
24
 
25
25
  const someMutation = {
26
26
  id: "Test Action",
27
- mutate: (() => {}) as unknown as (a: number, b: string) => Effect.Effect<string, number, CommandContext>
27
+ mutate: (() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>
28
28
  } as const
29
29
  const someMutation2 = Object.assign(
30
- (() => {}) as unknown as (a: number, b: string) => Effect.Effect<string, number, CommandContext>,
30
+ (() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>,
31
31
  {
32
32
  id: "Test Action"
33
33
  } as const
@@ -252,16 +252,19 @@ it.live("can receive and use input", () =>
252
252
  let executed = false
253
253
 
254
254
  const command = Command.fn("Test Action")(
255
- function*(input1: number, input2: string) {
255
+ function*(input1: number, input2) {
256
256
  expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
257
257
 
258
258
  return { input1, input2 }
259
259
  },
260
260
  Effect.tap(() => executed = true)
261
261
  )
262
- const r = yield* unwrap(command.handle(1, "2"))
262
+ const r = yield* unwrap(command.handle(1))
263
263
 
264
- expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input.
264
+ expect(r.input1).toBe(1) // to confirm that the initial function has ran and received input.
265
+ const { handle, result, waiting, ...rest } = command
266
+ const ctx = { ...rest, state: undefined }
267
+ expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx))
265
268
  expect(executed).toBe(true) // to confirm that the combinators have ran.
266
269
  }))
267
270
 
@@ -547,19 +550,25 @@ it.live("can receive and use input with alt", () =>
547
550
 
548
551
  let executed = false
549
552
 
550
- const command = Command.alt("Test Action")(
551
- Effect.fnUntraced(
552
- function*(input1: number, input2: string) {
553
- expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
553
+ const command = Command.alt("Test Action")((input1: number, input2) =>
554
+ Effect
555
+ .gen(
556
+ function*() {
557
+ expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
554
558
 
555
- return { input1, input2 }
556
- },
557
- Effect.tap(() => executed = true)
558
- )
559
+ return { input1, input2 }
560
+ }
561
+ )
562
+ .pipe(
563
+ Effect.tap(() => executed = true)
564
+ )
559
565
  )
560
- const r = yield* unwrap(command.handle(1, "2"))
566
+ const r = yield* unwrap(command.handle(1))
561
567
 
562
- expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input.
568
+ const { handle, result, waiting, ...rest } = command
569
+ const ctx = { ...rest, state: undefined }
570
+ expect(r.input1).toBe(1)
571
+ expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx)) // to confirm that the initial function has ran and received input.
563
572
  expect(executed).toBe(true) // to confirm that the combinators have ran.
564
573
  }))
565
574