MCPcopy Create free account
hub / github.com/effect-app/libs / effect

Function effect

packages/infra/test/controller.test.ts:297–350  ·  view source on GitHub ↗
(match)

Source from the content-addressed store, hash-verified

295 SomethingService2.Default
296 ],
297 *effect(match) {
298 const repo = yield* SomethingRepo
299 const smth = yield* SomethingService
300 const smth2 = yield* SomethingService2
301
302 // this gets catched in 'routes' type
303 if (Math.random() > 0.5) {
304 return yield* new InvalidStateError("ciao")
305 }
306
307 console.log({ repo, smth, smth2 })
308
309 return match({
310 Eff: () =>
311 Effect
312 .gen(function*() {
313 const some = yield* Some
314 return yield* Effect.logInfo("Some", some)
315 }),
316
317 *Gen() {
318 const some = yield* Some
319 return yield* Effect.logInfo("Some", some)
320 },
321 *GetSomething(req) {
322 console.log(req["id"])
323
324 const _b = yield* Effect.succeed(false)
325 if (_b) {
326 // expected errors here because RequestError is not a valid error for controllers
327 // yield* new RequestError(1 as any)
328 // return yield* new RequestError(1 as any)
329 }
330 if (Math.random() > 0.5) {
331 return yield* Effect.succeed("12")
332 }
333 if (!_b) {
334 return yield* Effect.fail(new UnauthorizedError())
335 } else {
336 // expected an error here because a boolean is not a string
337 // return _b
338 return "12"
339 }
340 },
341 DoSomething: {
342 *raw() {
343 return yield* Effect.succeed(undefined)
344 }
345 },
346 GetSomething2: {
347 raw: () => Some.use(() => Effect.succeed("12"))
348 }
349 })
350 }
351})
352
353it("sorts based on requirements", () => {

Callers 11

Effect.tsFile · 0.50
unwrapFunction · 0.50
Layer.tsFile · 0.50
spanFunction · 0.50
Atom.tsFile · 0.50
factoryFunction · 0.50
Command.tsFile · 0.50
makeFunction · 0.50
makeIndexedDbFunction · 0.50
groupCompactionFunction · 0.50
makeFunction · 0.50

Calls 4

logMethod · 0.65
useMethod · 0.65
matchFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…