Skip to content

Instantly share code, notes, and snippets.

View tanishqkancharla's full-sized avatar
🏠
Working from home

Tanishq Kancharla tanishqkancharla

🏠
Working from home
View GitHub Profile
class ExpoSqliteTupleStorageApi implements AsyncTupleStorageApi {
private db = SQLite.openDatabase("app.db");
constructor() {}
async prepare() {
await this.db.execAsync(
[
{
sql: `
@tanishqkancharla
tanishqkancharla / localDb.ts
Created March 12, 2024 04:20
Tuple-db ORM
import { isFunction, isSymbol } from "lodash-es";
import type {
KeyValuePair,
ReadOnlyTupleDatabaseClientApi,
TupleTransactionApi,
} from "tuple-database";
import {
InMemoryTupleStorage,
TupleDatabase,
TupleDatabaseClient,
@tanishqkancharla
tanishqkancharla / AnimatePresence.tsx
Last active January 16, 2024 04:01
AnimatePresence in React Native
import { unionBy } from "lodash-es";
import React, { ReactElement, useEffect, useState } from "react";
import { Animated, useAnimatedValue } from "react-native";
function diffBy<T>(a: T[], b: T[], key: keyof T) {
const aKeys = a.map((item) => item[key]);
const bKeys = b.map((item) => item[key]);
const added = b.filter((item) => !aKeys.includes(item[key]));
const removed = a.filter((item) => !bKeys.includes(item[key]));