@appbaseio/reactivecore
Advanced tools
Comparing version 0.1.4 to 0.2.0
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.addComponent=addComponent;exports.removeComponent=removeComponent;exports.watchComponent=watchComponent;exports.setQuery=setQuery;exports.setQueryOptions=setQueryOptions;exports.logQuery=logQuery;exports.executeQuery=executeQuery;exports.updateHits=updateHits;exports.updateAggs=updateAggs;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.setValue=setValue;exports.clearValues=clearValues;var _constants=require("../constants");var _helper=require("../utils/helper");function addComponent(component){return{type:_constants.ADD_COMPONENT,component:component};}function removeComponent(component){return{type:_constants.REMOVE_COMPONENT,component:component};}function updateWatchman(component,react){return{type:_constants.WATCH_COMPONENT,component:component,react:react};}function watchComponent(component,react){return function(dispatch,getState){dispatch(updateWatchman(component,react));var store=getState();var _buildQuery=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(queryObj&&Object.keys(queryObj).length||options&&"aggs"in options){dispatch(executeQuery(component,queryObj,options));}};}function setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}function setQueryOptions(component,queryOptions){return function(dispatch,getState){dispatch(updateQueryOptions(component,queryOptions));var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;if(queryObj&&Object.keys(queryObj).length||options&&"aggs"in options){dispatch(executeQuery(component,queryObj,options));}};}function updateQueryOptions(component,options){return{type:_constants.SET_QUERY_OPTIONS,component:component,options:options};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function executeQuery(component,query){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var appendToHits=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var onQueryChange=arguments[4];return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,queryLog=_getState.queryLog;var mainQuery=null;if(query){mainQuery={query:query};}var finalQuery=_extends({},mainQuery,options);if(!(0,_helper.isEqual)(finalQuery,queryLog[component])){console.log("Executing for",component,finalQuery);if(onQueryChange){onQueryChange(queryLog[component],finalQuery);}dispatch(logQuery(component,finalQuery));appbaseRef.search({type:config.type==="*"?null:config.type,body:finalQuery}).on("data",function(response){dispatch(updateHits(component,response.hits,appendToHits));if("aggregations"in response){dispatch(updateAggs(component,response.aggregations));}}).on("error",function(e){console.log(e);});}};}function updateHits(component,hits){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:_constants.UPDATE_HITS,component:component,hits:hits.hits,total:hits.total,append:append};}function updateAggs(component,aggregations){return{type:_constants.UPDATE_AGGS,component:component,aggregations:aggregations};}function updateQuery(componentId,query,onQueryChange){return function(dispatch,getState){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}dispatch(setQuery(componentId,queryToDispatch));var store=getState();var watchList=store.watchMan[componentId];if(Array.isArray(watchList)){watchList.forEach(function(component){var _buildQuery3=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery3.queryObj,options=_buildQuery3.options;dispatch(executeQuery(component,queryObj,options,false,onQueryChange));});}};}function loadMore(component,newOptions){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){var store=getState();var _buildQuery4=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery4.queryObj,options=_buildQuery4.options;if(!options){options={};}options=_extends({},options,newOptions);dispatch(executeQuery(component,queryObj,options,append));};}function setValue(component,value){var label=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return{type:_constants.SET_VALUE,component:component,value:value,label:label};}function clearValues(){return{type:_constants.CLEAR_VALUES};} | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.addComponent=addComponent;exports.removeComponent=removeComponent;exports.watchComponent=watchComponent;exports.setQuery=setQuery;exports.setQueryOptions=setQueryOptions;exports.logQuery=logQuery;exports.executeQuery=executeQuery;exports.updateHits=updateHits;exports.updateAggs=updateAggs;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.clearValues=clearValues;var _constants=require("../constants");var _helper=require("../utils/helper");function addComponent(component){return{type:_constants.ADD_COMPONENT,component:component};}function removeComponent(component){return{type:_constants.REMOVE_COMPONENT,component:component};}function updateWatchman(component,react){return{type:_constants.WATCH_COMPONENT,component:component,react:react};}function watchComponent(component,react){return function(dispatch,getState){dispatch(updateWatchman(component,react));var store=getState();var _buildQuery=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(queryObj&&Object.keys(queryObj).length||options&&"aggs"in options){dispatch(executeQuery(component,queryObj,options));}};}function setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}function setQueryOptions(component,queryOptions){return function(dispatch,getState){dispatch(updateQueryOptions(component,queryOptions));var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;if(queryObj&&Object.keys(queryObj).length||options&&"aggs"in options){dispatch(executeQuery(component,queryObj,options));}};}function updateQueryOptions(component,options){return{type:_constants.SET_QUERY_OPTIONS,component:component,options:options};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function executeQuery(component,query){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var appendToHits=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var onQueryChange=arguments[4];return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,queryLog=_getState.queryLog;var mainQuery=null;if(query){mainQuery={query:query};}var finalQuery=_extends({},mainQuery,options);if(!(0,_helper.isEqual)(finalQuery,queryLog[component])){console.log("Executing for",component,finalQuery);if(onQueryChange){onQueryChange(queryLog[component],finalQuery);}dispatch(logQuery(component,finalQuery));appbaseRef.search({type:config.type==="*"?null:config.type,body:finalQuery}).on("data",function(response){dispatch(updateHits(component,response.hits,appendToHits));if("aggregations"in response){dispatch(updateAggs(component,response.aggregations));}}).on("error",function(e){console.log(e);});}};}function updateHits(component,hits){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:_constants.UPDATE_HITS,component:component,hits:hits.hits,total:hits.total,append:append};}function updateAggs(component,aggregations){return{type:_constants.UPDATE_AGGS,component:component,aggregations:aggregations};}function updateQuery(componentId,query,value){var label=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var onQueryChange=arguments[4];return function(dispatch,getState){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}dispatch(setValue(componentId,value,label));dispatch(setQuery(componentId,queryToDispatch));var store=getState();var watchList=store.watchMan[componentId];if(Array.isArray(watchList)){watchList.forEach(function(component){var _buildQuery3=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery3.queryObj,options=_buildQuery3.options;dispatch(executeQuery(component,queryObj,options,false,onQueryChange));});}};}function loadMore(component,newOptions){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){var store=getState();var _buildQuery4=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery4.queryObj,options=_buildQuery4.options;if(!options){options={};}options=_extends({},options,newOptions);dispatch(executeQuery(component,queryObj,options,append));};}function setValue(component,value,label){return{type:_constants.SET_VALUE,component:component,value:value,label:label};}function clearValues(){return{type:_constants.CLEAR_VALUES};} |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -61,3 +61,3 @@ # `reactivecore` | ||
| `getAggsOrder` | returns aggs order query based on `sortBy` prop | | ||
| `checkPropChange` | checks for props changes that would need to update the query via callback | | ||
| `checkSomePropChange` | checks for any prop change in the propsList and invokes the callback | | ||
| `checkPropChange` | checks for props changes that would need to update the query via callback | | ||
| `checkSomePropChange` | checks for any prop change in the propsList and invokes the callback | |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
44074
1