Skip to content

Commit

Permalink
add jsdoc comment for CreatedAt
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaskasky committed Jul 31, 2024
1 parent 4076e74 commit 48ed9fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vanilla/utils/atomFamily.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { type Atom } from '../../vanilla.ts'

type ShouldRemove<Param> = (createdAt: number, param: Param) => boolean
/**
* in milliseconds
*/
type CreatedAt = number
type ShouldRemove<Param> = (createdAt: CreatedAt, param: Param) => boolean
type Cleanup = () => void
type Callback<Param, AtomType> = (event: {
type: 'CREATE' | 'REMOVE'
Expand Down Expand Up @@ -29,7 +33,6 @@ export function atomFamily<Param, AtomType extends Atom<unknown>>(
initializeAtom: (param: Param) => AtomType,
areEqual?: (a: Param, b: Param) => boolean,
) {
type CreatedAt = number // in milliseconds
let shouldRemove: ShouldRemove<Param> | null = null
const atoms: Map<Param, [AtomType, CreatedAt]> = new Map()
const listeners = new Set<Callback<Param, AtomType>>()
Expand Down

0 comments on commit 48ed9fa

Please sign in to comment.