Skip to content

Rewrite IndexedDB types to [<ParamObject>]? #126

@SimenLK

Description

@SimenLK

Hey, pulled in the new changes to IndexedDB which changed some things up, but since I had been using a lot of dynamic typing in my original implementations, I tried using the newly added proper types.

Kinda annoying to work with interfaces, though the jsOptions isn't too bad:

let archives =
    db.createObjectStore("ArchivePolygons", jsOptions (fun o ->
        o.keyPath <- "ArchiveUuid"
    ))

Looking at paraobject, however, seems like the nicest option:

let archives =
    db.createObjectStore("ArchivePolygons", IDBCreateStoreOptions("ArchiveUuid"))

If we ignore the terrible interface names for IndexedDB, of course :) So from:

type [<AllowNullLiteral; Global>] IDBCreateStoreOptions =
    abstract keyPath: obj with get, set
    abstract autoIncrement: bool with get, set

to:

[<AllowNullLiteral; Global>]
type IDBCreateStoreOptions
    [<ParamObject; Emit($0)>]
    (
        keyPath: obj,
        ?autoIncrement: bool
    )
    =
    member val keyPath: obj = jsNative with get, set
    member val autoIncrement: bool = jsNative with get, set

@MangelMaxime, where do you stand on this? And @robitar, are you using IndexedDB, and would it break your applications?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions