0.0.11 • Published 7 months ago

@medical-district/client-db v0.0.11

Weekly downloads
-
License
Plant stem cell l...
Repository
-
Last release
7 months ago

Client DB

literature

A DB that exists while a browser page is open.
It doesn't interface with cookies, localStorage, etc. 

ecmascript

import { MAKE_DB } from '@medical-district/client-db'


/*
	Function series of functions that are only called once:

		STORAGE
		AT.START
*/
const DB = await MAKE_DB ({
	STORAGE: async function () {
		return {
			S: 1
		}
	},

	PLAYS: {
		async PLAY_1 ({ CHANGE, STORAGE }, { PARAM_1 }) {			
			let S = (await STORAGE ()).S
			await CHANGE ("S", S + 1)
		}
	},
	
	AT: {
		async START ({ PLAYS, STORAGE }) {
			await PLAYS.PLAY_1 ({ REPEAT: 1 })
		}
	}			
})	

/*
	DB Subscriptions:
	
	Calls:
		The subscribe function is called once when
		instantiated with: FIRST === true
		
		Then again every time a play is called,
		for example:
		
			await DB.PLAYS.PLAY_1 ({ PARAM_1: 10 })
			
	Unsubscribing:
		UNSUBSCRIBE ()
*/		
const UNSUBSCRIBE = DB.SUBSCRIBE (({ FIRST }) => {
	const STORAGE = DB.STORAGE ()

	console.log ({ STORAGE })
})

/*
	After subscribing, the subscriber count is 1
*/
assert.equal (DB.SUBSCRIBER_COUNT (), 1)


//
//	Plays
//
await DB.PLAYS.PLAY_1 ({ PARAM_1: 10 })


UNSUBSCRIBE ()

/*
	After unsubscribing, the subscriber count
*/
assert.equal (DB.SUBSCRIBER_COUNT (), 0)

Publishing, tcsh

First Publish

git commit -am --allow-empty && npm publish --access public

Later Publishes

yarn run status && git add --all && git commit -m --allow-empty && npm version patch && npm publish --access public
0.0.11

7 months ago

0.0.10

7 months ago

0.0.9

7 months ago

0.0.8

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago