gongo-client-react
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -7,7 +7,7 @@ import { Database, Cursor } from "gongo-client"; | ||
declare type CursorFunc<DocType extends Document> = (db: Database) => Cursor<DocType>; | ||
declare const useGongoCursor: <DocType extends Document>(cursorFunc: CursorFunc<DocType>, opts?: useGongoCursorOpts) => Cursor<DocType>; | ||
declare const useGongoLive: <DocType extends Document>(cursorFunc: CursorFunc<DocType>, opts?: useGongoCursorOpts) => import("gongo-client/lib/browser/Collection").WithId<DocType>[]; | ||
declare const useGongoOne: <DocType extends Document>(origCursorFunc: CursorFunc<DocType>, opts?: useGongoCursorOpts) => import("gongo-client/lib/browser/Collection").WithId<DocType>; | ||
declare const useGongoCursor: <DocType extends Document>(cursorFunc: false | CursorFunc<DocType> | null | undefined, opts?: useGongoCursorOpts) => false | Cursor<DocType> | null | undefined; | ||
declare const useGongoLive: <DocType extends Document>(cursorFunc: false | CursorFunc<DocType> | null | undefined, opts?: useGongoCursorOpts) => import("gongo-client/lib/browser/Collection").WithId<DocType>[]; | ||
declare const useGongoOne: <DocType extends Document>(origCursorFunc: CursorFunc<DocType>, opts?: useGongoCursorOpts) => import("gongo-client/lib/browser/Collection").WithId<DocType> | null; | ||
declare function useGongoUserId(): unknown; | ||
export { useGongoCursor, useGongoLive, useGongoOne, useGongoUserId }; | ||
//# sourceMappingURL=liveQueries.d.ts.map |
@@ -25,2 +25,3 @@ "use strict"; | ||
if (newCursor && | ||
cursor && | ||
// BUG FIX from: newCursor._skip === cursor.skip (not _skip)... untested! | ||
@@ -64,7 +65,10 @@ !(newCursor._skip === cursor._skip && newCursor._limit === cursor._limit)) { | ||
function cursorFunc(db) { | ||
const cursor = origCursorFunc(db); | ||
const cursor = origCursorFunc && origCursorFunc(db); | ||
return cursor && cursor.limit(1); | ||
} | ||
const data = useGongoLive(cursorFunc, opts); | ||
return data[0]; | ||
if (data.length > 0) | ||
return data[0]; | ||
else | ||
return null; | ||
}; | ||
@@ -71,0 +75,0 @@ exports.useGongoOne = useGongoOne; |
{ | ||
"name": "gongo-client-react", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Gadi Cohen <dragon@wastelands.net>", | ||
@@ -5,0 +5,0 @@ "description": "React hooks for GongoJS gongo-client", |
@@ -15,3 +15,3 @@ import { useState, useEffect, useMemo } from "react"; | ||
const useGongoCursor = <DocType extends Document>( | ||
cursorFunc: CursorFunc<DocType>, | ||
cursorFunc: CursorFunc<DocType> | null | undefined | false, | ||
opts?: useGongoCursorOpts | ||
@@ -37,2 +37,3 @@ ) => { | ||
newCursor && | ||
cursor && | ||
// BUG FIX from: newCursor._skip === cursor.skip (not _skip)... untested! | ||
@@ -76,3 +77,3 @@ !(newCursor._skip === cursor._skip && newCursor._limit === cursor._limit) | ||
const useGongoLive = <DocType extends Document>( | ||
cursorFunc: CursorFunc<DocType>, | ||
cursorFunc: Parameters<typeof useGongoCursor<DocType>>[0], | ||
opts?: useGongoCursorOpts | ||
@@ -95,7 +96,8 @@ ) => { | ||
function cursorFunc(db: Database) { | ||
const cursor = origCursorFunc(db); | ||
const cursor = origCursorFunc && origCursorFunc(db); | ||
return cursor && cursor.limit(1); | ||
} | ||
const data = useGongoLive(cursorFunc, opts); | ||
return data[0]; | ||
if (data.length > 0) return data[0]; | ||
else return null; | ||
}; | ||
@@ -102,0 +104,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35937
686