Skip to content

Instantly share code, notes, and snippets.

@evelant
evelant / textdecoder.js
Created May 7, 2024 19:24
fastestsmallesttextencoderdecoder TextDecoder polyfill fixed for react-native 0.74
(function(window){
"use strict";
var log = Math.log;
var LN2 = Math.LN2;
var clz32 = Math.clz32 || function(x) {return 31 - log(x >>> 0) / LN2 | 0};
var fromCharCode = String.fromCharCode;
var Object_prototype_toString = ({}).toString;
var NativeSharedArrayBuffer = window["SharedArrayBuffer"];
var sharedArrayBufferString = NativeSharedArrayBuffer ? Object_prototype_toString.call(NativeSharedArrayBuffer) : "";
var NativeUint8Array = window.Uint8Array;
/**
* @since 1.0.0
*/
import * as Reactivity from "@effect/experimental/Reactivity"
import * as Client from "@effect/sql/SqlClient"
import type { Connection } from "@effect/sql/SqlConnection"
import { SqlError } from "@effect/sql/SqlError"
import type { Custom, Fragment, Primitive } from "@effect/sql/Statement"
import * as Statement from "@effect/sql/Statement"
import { PGlite, types, type Results, type Transaction } from "@electric-sql/pglite"
@evelant
evelant / ElectricSyncService.ts
Created April 8, 2025 16:50
effect-ts streams for up-to-date with electric sql
export class ElectricSyncService extends Effect.Service<ElectricSyncService>()(
"ElectricSyncService",
{
scoped: Effect.gen(function* () {
yield* Effect.logInfo(`creating ElectricSyncService`)
const clockService = yield* ClockService
const syncService = yield* SyncService
const config = yield* SynchrotronClientConfig
const pgLiteClient = yield* PgLiteSyncTag