Initial commit
This commit is contained in:
26
packages/example/.gitignore
vendored
Normal file
26
packages/example/.gitignore
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
.tanstack
|
||||
0
packages/example/README.md
Normal file
0
packages/example/README.md
Normal file
8
packages/example/biome.json
Normal file
8
packages/example/biome.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/latest/schema.json",
|
||||
"root": false,
|
||||
"extends": "//",
|
||||
"files": {
|
||||
"includes": ["./src/**"]
|
||||
}
|
||||
}
|
||||
19
packages/example/package.json
Normal file
19
packages/example/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "@effect-lens/example",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint:tsc": "tsc --noEmit",
|
||||
"lint:biome": "biome lint",
|
||||
"clean:cache": "rm -rf .turbo",
|
||||
"clean:modules": "rm -rf node_modules"
|
||||
},
|
||||
"dependencies": {
|
||||
"effect": "^3.21.0",
|
||||
"effect-lens": "workspace:*"
|
||||
},
|
||||
"overrides": {
|
||||
"effect": "^3.21.0"
|
||||
}
|
||||
}
|
||||
20
packages/example/src/quickstart.ts
Normal file
20
packages/example/src/quickstart.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Array, Console, Effect, Stream, SubscriptionRef } from "effect"
|
||||
import { Lens } from "effect-lens"
|
||||
|
||||
Effect.gen(function*() {
|
||||
// The ref is the data source
|
||||
const ref = yield* SubscriptionRef.make([12, 87, 69])
|
||||
|
||||
// The lens acts as a proxy that allows reading, subscribing from and writing to that
|
||||
// data source with a similar API to Effect's SubscriptionRef
|
||||
const lens = Lens.fromSubscriptionRef(ref)
|
||||
// ^ Lens.Lens<number[], never, never, never, never>
|
||||
|
||||
const value = yield* Lens.get(lens)
|
||||
yield* Effect.forkScoped(Stream.runForEach(lens.changes, Console.log))
|
||||
yield* Lens.update(lens, Array.replace(1, 1664))
|
||||
})
|
||||
|
||||
Effect.gen(function*() {
|
||||
|
||||
})
|
||||
39
packages/example/tsconfig.json
Normal file
39
packages/example/tsconfig.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"target": "ESNext",
|
||||
"module": "NodeNext",
|
||||
"moduleDetection": "force",
|
||||
"jsx": "react-jsx",
|
||||
// "allowJs": true,
|
||||
|
||||
// Bundler mode
|
||||
"moduleResolution": "NodeNext",
|
||||
// "allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
// "noEmit": true,
|
||||
|
||||
// Best practices
|
||||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
|
||||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
|
||||
// Build
|
||||
"outDir": "./dist",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
|
||||
"plugins": [
|
||||
{ "name": "@effect/language-service" }
|
||||
]
|
||||
},
|
||||
|
||||
"include": ["./src"],
|
||||
"exclude": ["**/*.test.ts", "**/*.spec.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user