experimenting with path encoding + events...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-09-20 01:00:44 +03:00
parent 888f303a4a
commit d83711ff73
3 changed files with 21 additions and 4 deletions

View File

@ -50,6 +50,13 @@ module = {
// XXX or can we?
SYSTEM_PATH: '/.system',
// XXX EXPERIMENTAL
encode: function(str){
return str
.replace(/[#:*%]/g, encodeURIComponent) },
decode: function(str){
return decodeURIComponent(str) },
/*/ XXX NORMCACHE...
__normalized_cache_threshold: 100,
__normalized_cache_size: 4096,

View File

@ -140,6 +140,9 @@ module.BaseStore = {
// XXX revise naming...
next: undefined,
onUpdate: types.event.Event('update'),
onDelete: types.event.Event('delete'),
// NOTE: .data is not part of the spec and can be implementation-specific,
// only .__<name>__(..) use it internally... (XXX check this)
__data: undefined,
@ -542,6 +545,7 @@ module.BaseStore = {
await this.__update__(path, data, mode)
// XXX CACHED
this.__cache_add(path)
this.onUpdate(path)
return this },
__delete__: async function(path){
delete this.data[path] },
@ -554,7 +558,8 @@ module.BaseStore = {
if(path){
await this.__delete__(path)
// XXX CACHED
this.__cache_remove(path) }
this.__cache_remove(path)
this.onDelete(path) }
return this },
// XXX NEXT might be a good idea to have an API to move pages from

View File

@ -6,10 +6,15 @@
* - fs store/export in browser or a simple way to export/import...
*
*
* XXX need page names to contain odd characters when created by user, for
* example: note titles...
* ...and need this to work through all the i/o...
* ....this might be an argument towards the .title attr, at least
* for notes...
* XXX need basic system events:
* <page>.onUpdate(path, data?)
* <page>.onUreate(path, data?)
* <page>.onDelete(path)
* <store>.onUpdate(path, data?)
* <store>.onCreate(path, data?)
* <store>.onDelete(path)
* ..stores should also be able to trigger these when external
* updates are detected...
* XXX CACHE strategy and architecture