Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

avenger

Package Overview
Dependencies
Maintainers
8
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avenger - npm Package Compare versions

Comparing version 5.0.0-20 to 5.0.0-21

1

lib/Query.d.ts

@@ -12,2 +12,3 @@ import { TaskEither } from 'fp-ts/lib/TaskEither';

_P: P;
inputSetoid: Setoid<A>;
run: Fetch<A, L, P>;

@@ -14,0 +15,0 @@ invalidate: Fetch<A, L, P>;

7

lib/Query.js

@@ -17,2 +17,3 @@ "use strict";

var Strategy_1 = require("./Strategy");
var Setoid_1 = require("fp-ts/lib/Setoid");
var CacheValue_1 = require("./CacheValue");

@@ -26,3 +27,3 @@ var Record_1 = require("fp-ts/lib/Record");

var cache = new Cache_1.Cache(fetch, strategy);
return __assign({ type: 'cached' }, queryPhantoms(), { cache: cache, run: cache.run, invalidate: cache.invalidate });
return __assign({ type: 'cached' }, queryPhantoms(), { inputSetoid: strategy.inputSetoid, cache: cache, run: cache.run, invalidate: cache.invalidate });
};

@@ -44,3 +45,3 @@ }

function compose(master, slave) {
return __assign({ type: 'composition' }, queryPhantoms(), { master: master, slave: slave, run: function (a1) {
return __assign({ type: 'composition' }, queryPhantoms(), { inputSetoid: master.inputSetoid, master: master, slave: slave, run: function (a1) {
return master.run(a1).chain(function (a2) {

@@ -66,3 +67,3 @@ return slave.run(a2);

var invalidate = function (a) { return sequenceRecordTaskEither(invalidateQueries(a)); };
return __assign({ type: 'product' }, queryPhantoms(), { queries: queries, run: run, invalidate: invalidate });
return __assign({ type: 'product' }, queryPhantoms(), { inputSetoid: Setoid_1.contramap(function (i) { return i || {}; }, Setoid_1.getRecordSetoid(Record_1.map(queries, function (q) { return q.inputSetoid; }))), queries: queries, run: run, invalidate: invalidate });
}

@@ -69,0 +70,0 @@ exports.product = product;

@@ -75,3 +75,3 @@ "use strict";

DeclareQueriesWrapper.prototype.componentDidUpdate = function (prevProps) {
if (prevProps.queries !== this.props.queries) {
if (!this.product.inputSetoid.equals(prevProps.queries, this.props.queries)) {
this.unsubscribe();

@@ -78,0 +78,0 @@ this.subscribe();

@@ -8,5 +8,21 @@ "use strict";

var Observable_1 = require("../Observable");
var Option_1 = require("fp-ts/lib/Option");
function usePrevious(value) {
var ref = react_1.useRef();
react_1.useEffect(function () {
ref.current = value;
});
return Option_1.fromNullable(ref.current);
}
function useQueryMonoid(query, resultMonoid, input) {
var _a = react_1.useState(resultMonoid.empty), state = _a[0], setState = _a[1];
var previousInput = usePrevious(input);
var inputEqualityRef = react_1.useRef();
react_1.useEffect(function () {
var inputChanged = previousInput.fold(true, function (previousInput) { return !query.inputSetoid.equals(previousInput, input); });
if (inputChanged) {
inputEqualityRef.current = (inputEqualityRef.current || 0) + 1;
}
});
react_1.useEffect(function () {
var subscription = Observable_1.observable

@@ -18,3 +34,3 @@ .map(observe_1.observeShallow(query, input), function (r) { return resultMonoid.concat(state, r); })

};
}, [input, query, setState]);
}, [inputEqualityRef.current, query, setState]);
return state;

@@ -21,0 +37,0 @@ }

{
"name": "avenger",
"version": "5.0.0-20",
"version": "5.0.0-21",
"description": "A CQRS-flavoured data fetching and caching layer in JavaScript. Batching, caching, data-dependecies and manual invalidations in a declarative fashion for node and the browser",

@@ -5,0 +5,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc