🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

lom_atom

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lom_atom - npm Package Compare versions

Comparing version

to
3.0.6

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

<a name="3.0.6"></a>
## [3.0.6](https://github.com/zerkalica/lom_atom/compare/v3.0.5...v3.0.6) (2017-11-30)
<a name="3.0.5"></a>

@@ -7,0 +12,0 @@ ## [3.0.5](https://github.com/zerkalica/lom_atom/compare/v3.0.4...v3.0.5) (2017-11-29)

19

dist/lom_atom.es.js

@@ -750,5 +750,3 @@ function _defineProperties(target, props) {

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -831,5 +829,3 @@

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -847,13 +843,11 @@

function cache(data) {
isForceCache = true;
isForceCache = false;
return data;
}
function reset(data) {}
Object.defineProperties(mem, {
reset: {
cache: {
get: function get() {
isForceCache = true;
return reset;
return cache;
}

@@ -864,5 +858,2 @@ },

},
cache: {
value: cache
},
key: {

@@ -869,0 +860,0 @@ value: memkey

@@ -754,5 +754,3 @@ 'use strict';

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -835,5 +833,3 @@

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -851,13 +847,11 @@

function cache(data) {
isForceCache = true;
isForceCache = false;
return data;
}
function reset(data) {}
Object.defineProperties(mem, {
reset: {
cache: {
get: function get() {
isForceCache = true;
return reset;
return cache;
}

@@ -868,5 +862,2 @@ },

},
cache: {
value: cache
},
key: {

@@ -873,0 +864,0 @@ value: memkey

@@ -756,5 +756,3 @@ (function (global, factory) {

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -837,5 +835,3 @@

var force = isForceCache;
isForceCache = false;
return atom.value(next, force);
return atom.value(next, isForceCache);
}

@@ -853,13 +849,11 @@

function cache(data) {
isForceCache = true;
isForceCache = false;
return data;
}
function reset(data) {}
Object.defineProperties(mem, {
reset: {
cache: {
get: function get() {
isForceCache = true;
return reset;
return cache;
}

@@ -870,5 +864,2 @@ },

},
cache: {
value: cache
},
key: {

@@ -875,0 +866,0 @@ value: memkey

{
"name": "lom_atom",
"version": "3.0.5",
"version": "3.0.6",
"description": "Alternative implementation of eigenmethod mol_atom state management library",

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

@@ -73,3 +73,3 @@ # lom_atom

Lom atom memoized property can interact with upstream (server, etc). Each observable or computed property can be used in 6 cases: get, force get, set, force set, reset, push. Modifiers helps to produce and control side effects for making network requests.
Lom atom memoized property can interact with upstream (server, etc). Each observable or computed property can be used in 4 cases: get, set, cache set, cache reset. Modifiers helps to produce and control side effects for making network requests.

@@ -81,3 +81,3 @@

class TodoList {
@mem set todos(todos: Todo) {
@mem set todos(todos: Todo | Error) {
fetch({

@@ -88,3 +88,4 @@ url: '/todos',

})
.catch(error => this.todos = mem.cache(error))
.then((data) => mem.cache(this.todos = data))
.catch(error => mem.cache(this.todos = error))

@@ -96,11 +97,23 @@ console.log('set handler')

@mem get todos() {
@mem get todos(): Todos {
console.log('get handler')
fetch('/todos')
.then((data) => this.todos = mem.cache(data))
.catch(error => this.todos = mem.cache(error))
.then((data) => mem.cache(this.todos = data))
.catch(error => mem.cache(this.todos = error))
throw new mem.Wait()
}
@mem.manual get user(): IUser {
fetch('/user')
.then((data) => mem.cache(this.user = data))
.catch(error => mem.cache(this.user = error))
}
set user(next: IUser | Error) {}
@mem todosWithUser() {
return {todos: this.todos, user: this.user}
}
}

@@ -110,10 +123,8 @@ const list = new TodoList()

| Modifier usage | Description | When call handler | Handler |
|-------------------------------------|--------------------------------------------------------|---------------------------------------|--------------------------------------|
| ``` store.todos ``` | Try to get value from cache, if empty - fetch upstream | If cache is empty or upstream changed | ``` get todos (): Todo[] {} ``` |
| ``` store.todos = mem.force() ``` | Reset cache and force load from upstream | Always | ``` get todos (): Todo[] {} ``` |
| ``` store.todos = [] ``` | Set value to upstream | If value is differs from cache | ``` set todos (todos: Todo[]) {} ``` |
| ``` store.todos = mem.force([]) ``` | Force set value to upstream | If value is differs from cache | ``` set todos (todos: Todo[]) {} ``` |
| ``` store.todos = mem.cache() ``` | Reset cache, but not fetch from upstream | Never | No |
| ``` store.todos = mem.cache([]) ``` | Save async answer from upstream to cache | Never | No |
* ``` this.todos ``` - get value, if cache is empty - invokes ``` get todos ``` and actualize cache.
* ``` this.todos = data ``` - set value, if cache empty - pass value to ``` set todos() {} ``` and actualize cache.
* ``` mem.cache(this.todos = data) ``` - set new value or error directly into cache (push).
* ``` mem.cache(list.todosWithUser) ``` - deep reset cache for todosWithUser all its dependencies (todos) and notify all dependants about changes.
* ``` @mem.manual get user() {...} ``` - exclude user from deep reset. ``` mem.reset(list.todosWithUser) ``` resets todos but not user. If you want to reset user, use helper directly on user: ``` mem.cache(list.user) ```
## Key-value

@@ -120,0 +131,0 @@

@@ -53,6 +53,3 @@ // @flow

}
const force = isForceCache
isForceCache = false
return atom.value(next, force)
return atom.value(next, isForceCache)
}

@@ -144,6 +141,3 @@ if (descr.value !== undefined) {

const force = isForceCache
isForceCache = false
return (atom: IAtom<V>).value(next, force)
return (atom: IAtom<V>).value(next, isForceCache)
}

@@ -175,19 +169,15 @@

function cache<V>(data: V): V {
isForceCache = true
isForceCache = false
return data
}
function reset<V>(data: V): void {}
(Object: any).defineProperties(mem, {
reset: {
get<V>(): (v: V) => void {
cache: {
get<V>(): (v: V) => V {
isForceCache = true
return reset
return cache
}
},
manual: { value: memManual },
cache: { value: cache },
key: { value: memkey },

@@ -209,3 +199,2 @@ Wait: { value: AtomWait }

cache<V>(v: V): V;
reset<V>(v: V): void;

@@ -212,0 +201,0 @@ key: IMemKey;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet