(
options:
| PositionOptions & {
readonly bufferSize?: number | undefined
}
| undefined
)
| 74 | } |
| 75 | |
| 76 | const makeQueue = ( |
| 77 | options: |
| 78 | | PositionOptions & { |
| 79 | readonly bufferSize?: number | undefined |
| 80 | } |
| 81 | | undefined |
| 82 | ) => |
| 83 | Queue.sliding<Either.Either<GeolocationPosition, GeolocationError>>(options?.bufferSize ?? 16).pipe( |
| 84 | Effect.tap((queue) => |
| 85 | Effect.acquireRelease( |
| 86 | Effect.sync(() => |
| 87 | navigator.geolocation.watchPosition( |
| 88 | (position) => queue.unsafeOffer(Either.right(position)), |
| 89 | (cause) => { |
| 90 | if (cause.code === cause.PERMISSION_DENIED) { |
| 91 | queue.unsafeOffer(Either.left(new GeolocationError({ reason: "PermissionDenied", cause }))) |
| 92 | } else if (cause.code === cause.TIMEOUT) { |
| 93 | queue.unsafeOffer(Either.left(new GeolocationError({ reason: "Timeout", cause }))) |
| 94 | } |
| 95 | }, |
| 96 | options |
| 97 | ) |
| 98 | ), |
| 99 | (handleId) => Effect.sync(() => navigator.geolocation.clearWatch(handleId)) |
| 100 | ) |
| 101 | ) |
| 102 | ) |
| 103 | |
| 104 | /** |
| 105 | * @since 1.0.0 |
no test coverage detected
searching dependent graphs…