Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/huge-bobcats-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-app/vue": minor
---

Change Commander to be unary and pass Context as second arg.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@effect/language-service": "0.41.1",
"@effect/platform": "^0.92.0",
"@effect/platform-node": "^0.98.0",
"@effect/vitest": "^0.26.0",
"@tsconfig/strictest": "^2.0.6",
"@types/lodash": "^4.17.20",
"@types/node": "~24.6.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"types": "./dist/experimental/commander.d.ts",
"default": "./dist/experimental/commander.js"
},
"./experimental/commander2": {
"types": "./dist/experimental/commander2.d.ts",
"default": "./dist/experimental/commander2.js"
},
"./experimental/confirm": {
"types": "./dist/experimental/confirm.d.ts",
"default": "./dist/experimental/confirm.js"
Expand Down
665 changes: 349 additions & 316 deletions packages/vue/src/experimental/commander.ts

Large diffs are not rendered by default.

39 changes: 24 additions & 15 deletions packages/vue/test/Mutation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ describe("alt2", () => {

const someMutation = {
id: "Test Action",
mutate: (() => {}) as unknown as (a: number, b: string) => Effect.Effect<string, number, CommandContext>
mutate: (() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>
} as const
const someMutation2 = Object.assign(
(() => {}) as unknown as (a: number, b: string) => Effect.Effect<string, number, CommandContext>,
(() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>,
{
id: "Test Action"
} as const
Expand Down Expand Up @@ -252,16 +252,19 @@ it.live("can receive and use input", () =>
let executed = false

const command = Command.fn("Test Action")(
function*(input1: number, input2: string) {
function*(input1: number, input2) {
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")

return { input1, input2 }
},
Effect.tap(() => executed = true)
)
const r = yield* unwrap(command.handle(1, "2"))
const r = yield* unwrap(command.handle(1))

expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input.
expect(r.input1).toBe(1) // to confirm that the initial function has ran and received input.
const { handle, result, waiting, ...rest } = command
const ctx = { ...rest, state: undefined }
expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx))
expect(executed).toBe(true) // to confirm that the combinators have ran.
}))

Expand Down Expand Up @@ -547,19 +550,25 @@ it.live("can receive and use input with alt", () =>

let executed = false

const command = Command.alt("Test Action")(
Effect.fnUntraced(
function*(input1: number, input2: string) {
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
const command = Command.alt("Test Action")((input1: number, input2) =>
Effect
.gen(
function*() {
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")

return { input1, input2 }
},
Effect.tap(() => executed = true)
)
return { input1, input2 }
}
)
.pipe(
Effect.tap(() => executed = true)
)
)
const r = yield* unwrap(command.handle(1, "2"))
const r = yield* unwrap(command.handle(1))

expect(r).toEqual({ input1: 1, input2: "2" }) // to confirm that the initial function has ran and received input.
const { handle, result, waiting, ...rest } = command
const ctx = { ...rest, state: undefined }
expect(r.input1).toBe(1)
expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx)) // to confirm that the initial function has ran and received input.
expect(executed).toBe(true) // to confirm that the combinators have ran.
}))

Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

4 changes: 3 additions & 1 deletion vite.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import fs from "fs"
// ]
// })


export default function makeConfig(dirName?: string) {
const prefix = path.resolve(__dirname, "packages")
const packages = fs.readdirSync(prefix).map(f => prefix + "/" + f).filter(f => fs.lstatSync(f).isDirectory() )
Expand All @@ -21,7 +22,8 @@ export default function makeConfig(dirName?: string) {
test: {
include: ["./test/**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
reporters: "verbose",
globals: true
globals: true,
setupFiles: [path.join(__dirname, "vitest.setup.ts")],
},
resolve: {
alias: packages.map(pkg => ({ pkg, json: pkg + "/package.json"})).filter(_ => fs.existsSync(_.json)).reduce((acc, { pkg, json}) => {
Expand Down
3 changes: 3 additions & 0 deletions vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { addEqualityTesters } from "@effect/vitest"

addEqualityTesters()