0.3.0 bump version to 0.3.0 in anticipation of use in 3-2020 light deployment
working without bugsmaster
parent
205f9a2ccd
commit
7730a94d3d
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@uci-utils/ready",
|
"name": "@uci-utils/ready",
|
||||||
"version": "0.1.10",
|
"version": "0.3.0",
|
||||||
"description": "A Class to Observe the reduced to boolean combined state of a map of observables",
|
"description": "A Class to Observe the reduced to boolean combined state of a map of observables",
|
||||||
"main": "src/ready.js",
|
"main": "src/ready.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"esm": "^3.2.25",
|
"esm": "^3.2.25",
|
||||||
"mocha": "^7.0.1",
|
"mocha": "^7.1.0",
|
||||||
"nodemon": "^2.0.2"
|
"nodemon": "^2.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
15
src/ready.js
15
src/ready.js
|
@ -29,7 +29,6 @@ class Ready extends Map {
|
||||||
if (opts.verbose||process.env.UCI_READY_VERBOSE==='true') this.logger.subscribe(console.log)
|
if (opts.verbose||process.env.UCI_READY_VERBOSE==='true') this.logger.subscribe(console.log)
|
||||||
this.handler = opts.handler || ((ready) => {console.log('default handler', ready)})
|
this.handler = opts.handler || ((ready) => {console.log('default handler', ready)})
|
||||||
this._first = true // tracks first emission
|
this._first = true // tracks first emission
|
||||||
console.log('@uci-utils/ready package tag 0.1.10')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get observers(){return Array.from(this.keys())}
|
get observers(){return Array.from(this.keys())}
|
||||||
|
@ -37,16 +36,11 @@ class Ready extends Map {
|
||||||
get all() { return this._all}
|
get all() { return this._all}
|
||||||
|
|
||||||
get failed() {
|
get failed() {
|
||||||
// console.log('making failures from',this.state)
|
|
||||||
let failed = this.state
|
let failed = this.state
|
||||||
.filter(([,ready]) => {
|
.filter(([,ready]) => {
|
||||||
// console.log('in filter', ready)
|
|
||||||
// return !await this.getValue(name)
|
|
||||||
// ret = obs[0]
|
|
||||||
return !ready
|
return !ready
|
||||||
})
|
})
|
||||||
.map(obs=> {return {name:obs[0], details: this.getObserverDetails(obs[0])} })
|
.map(obs=> {return {name:obs[0], details: this.getObserverDetails(obs[0])} })
|
||||||
// console.log('failed as filtered', failed)
|
|
||||||
|
|
||||||
return failed.length ? failed : '__none__'
|
return failed.length ? failed : '__none__'
|
||||||
}
|
}
|
||||||
|
@ -66,7 +60,6 @@ class Ready extends Map {
|
||||||
|
|
||||||
getObserver(name) {
|
getObserver(name) {
|
||||||
return (this.get(name) || {}).obs
|
return (this.get(name) || {}).obs
|
||||||
// return (name==null ||'__all__') ? this._all : ( (this.get(name) || {}).obs || this._combinations.get(name) || false )
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getCombination(name) {
|
getCombination(name) {
|
||||||
|
@ -99,14 +92,11 @@ class Ready extends Map {
|
||||||
if (!obs || !isObservable(obs)) return false
|
if (!obs || !isObservable(obs)) return false
|
||||||
let xobs = obs.pipe(
|
let xobs = obs.pipe(
|
||||||
tap(val => this.log(`${name} emitted/resolved the value =>${JSON.stringify(val)}`)),
|
tap(val => this.log(`${name} emitted/resolved the value =>${JSON.stringify(val)}`)),
|
||||||
// tap(val => console.log(`${name} emitted/resolved the value =>${JSON.stringify(val)}`)),
|
|
||||||
// TODO retain plain object if it has a ready property
|
// TODO retain plain object if it has a ready property
|
||||||
map(condition),
|
map(condition),
|
||||||
// tap(val => console.log(`boolean: ${val}`)),
|
// tap(val => console.log(`boolean: ${val}`)),
|
||||||
tap(val => this.log(`boolean: ${val}`)),
|
tap(val => this.log(`boolean: ${val}`)),
|
||||||
map(val => {
|
map(val => {return opts.reverse ? !val : val}),
|
||||||
// if (opts.reverse) console.log('reversing', val, opts.reverse ? !val : val)
|
|
||||||
return opts.reverse ? !val : val}),
|
|
||||||
startWith(false),
|
startWith(false),
|
||||||
// shareReplay({refCount:true, bufferSize:1}),
|
// shareReplay({refCount:true, bufferSize:1}),
|
||||||
shareReplay(1),
|
shareReplay(1),
|
||||||
|
@ -125,7 +115,6 @@ class Ready extends Map {
|
||||||
if (!(obs || {})._readyType) obs = this.makeObserver(obs, opts)
|
if (!(obs || {})._readyType) obs = this.makeObserver(obs, opts)
|
||||||
if (!isObservable(obs)) return false
|
if (!isObservable(obs)) return false
|
||||||
let sub = obs.subscribe() // internal subscriber
|
let sub = obs.subscribe() // internal subscriber
|
||||||
// let sub = null
|
|
||||||
this.set(name, {obs:obs, sub:sub})
|
this.set(name, {obs:obs, sub:sub})
|
||||||
this.setObserverDetails(name,opts.details)
|
this.setObserverDetails(name,opts.details)
|
||||||
this._combineAll()
|
this._combineAll()
|
||||||
|
@ -178,8 +167,6 @@ class Ready extends Map {
|
||||||
if (!names) names = this.combinations // remove all
|
if (!names) names = this.combinations // remove all
|
||||||
if (!Array.isArray(names)) names = [names]
|
if (!Array.isArray(names)) names = [names]
|
||||||
names.forEach(name => {
|
names.forEach(name => {
|
||||||
// const sub = (this._combinations.get(name)||{}).sub
|
|
||||||
// if (sub) sub.unsubscribe() // remove attached subscription
|
|
||||||
this.unsubscribe(name) // remove any resigtered subscription
|
this.unsubscribe(name) // remove any resigtered subscription
|
||||||
this._combinations.delete(name)
|
this._combinations.delete(name)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue