Skip to content

Instantly share code, notes, and snippets.

@nabato
nabato / rtkQueryCacheUtils.ts
Created August 4, 2024 08:40 — forked from Shrugsy/rtkQueryCacheUtils.ts
RTK Query cache utils. Useful abstractions for creating `provides`/`invalidates` cache data tags against endpoints.
import { FetchBaseQueryError } from '@rtk-incubator/rtk-query/dist';
/**
* Default tags used by the cacher helpers
*/
const defaultTags = ["UNAUTHORIZED", "UNKNOWN_ERROR"] as const;
type DefaultTags = typeof defaultTags[number];
function concatErrorCache<T, ID>(
existingCache: CacheList<T, ID>,
@nabato
nabato / codeExamples.js
Created August 31, 2018 18:21
JS code examples
// ------------------------------------
// 1
// ------------------------------------
function* likeComment(action) {
const { comment_id, unlike } = action.payload
const user = yield select(selectUser)
const token = get(user, 'data.auth_token')
yield put(receiveLikedComment(comment_id, unlike))