location-service-map.ts 687 B

123456789101112131415161718
  1. import { Context, Effect, Layer, LayerMap } from "effect"
  2. import { LayerNode } from "./effect/layer-node"
  3. import { Node } from "./effect/app-node"
  4. import { Location } from "./location"
  5. import type { LocationError, LocationServices } from "./location-services"
  6. export class Service extends Context.Service<
  7. Service,
  8. LayerMap.LayerMap<Location.Ref, LocationServices, LocationError>
  9. >()("@kirincode/example/LocationServiceMap") {
  10. static get(ref: Location.Ref) {
  11. return Layer.unwrap(Effect.map(Service, (locations) => locations.get(ref)))
  12. }
  13. }
  14. export const node = LayerNode.unbound(Service, Node.tags.values.global)
  15. export * as LocationServiceMap from "./location-service-map"