-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create - STATE #30
Comments
Tasks -
|
Tasks -
|
feedback for worklog 238 and 239 First, I feel the worklog video is missing a lot of things.
I would be happy if you could structure future worklogs to cover all the outputs and changes you worked on. Either one after another, or if it doesnt fit into 5 minutes, then multiple worklog videos. Having said that, here my FEEDBACK: 😺
|
Tasks -
|
Tasks -
|
Tasks -
|
feedback Lets compare our current and potentially new approach 1// ----------------------------------------------------------------------------
// 1. make icon set its default fallback (=`FB_II`) using the `image.svg` in the above snippet
// icon.js
/***********
NOW:
***********/
function FB_II () {
return { 'image.svg': `<svg>▶️</svg>` }
}
/***********
vs. NEW:
***********/
function FB_II () {
return { 'image.svg': `<svg>▶️</svg>` }
} This is the same, no changes. 2// ----------------------------------------------------------------------------
// 3. make button override icon `image.svg`
// 2. set button default fallback (=`FB_IB1` + `FB_IB2`) to `label/size`
// btn.js
/***********
NOW:
***********/
function FB_IB () {
return {
0: { subs: [1], data: { label: 'button', size: 'small' } },
1: { type: 'icon', override: [override_icon] }
}
}
function override_icon (data) {
data[0].data['image.svg'] = `<svg>🧸</svg>`
return data
}
/***********
vs. NEW:
***********/
function FB_IB1 () {
return {
_: { icon: { 0: override } }, // icon === 'icon:0'
'data.json': { label: 'button', size: 'large' }
}
}
function FB_IB2 () {
return {
_: { icon: { 0: override } }, // icon === 'icon:0'
'data.json': { label: 'button', size: 'small' }
}
}
function override (data) {
data['image.svg'] = `<svg>🧸</svg>`
return data
} This is different.
3// ----------------------------------------------------------------------------
// 5. make menu code require 2 button module instances, one for small button, one for normal button
// 4. make menu (=`FB_IM`) override button label + reset icon back to original from what button changed
// menu.js
/***********
NOW:
***********/
function FB_MM () {
return { 0: { subs: ['btn'] } }
}
function FB_IM () {
return {
0: { subs: ['1', '2'] },
'1': { type: 'btn:small', override: [override_btn] },
'2': { type: 'btn:normal', override: [override_btn] }
}
}
function override_btn (data) {
data.label = 'beep boop'
Object.entries(data).forEach(([id, value]) => {
if (value.type.includes('icon')) data[id].override = null
})
}
/***********
vs. NEW:
***********/
// FB_MM
function FB_IM () {
return { _: { btn: { 0: override }, 'btn:1#small': { 0: override } } } // btn === 'btn:0'
}
function override (data) {
data['data.json'].label = 'beep boop'
data._['icon:0/0'] = ([icon]) => icon()
return data
}
4// ----------------------------------------------------------------------------
// app.js
// foo.js
// head.js
// ----------------------------------------------------------------------------
// 6. make nav (=`FB_IN`) undo the menu overide for button module instances
// nav.js
/***********
NOW:
***********/
function FB_IN () {
return {
0: { subs: ['1'] },
'1': { type: 'menu', override: [override_menu] }
}
}
function override_menu (data) {
Object.entries(data).forEach(([id, value]) => {
if (value.type.includes('btn')) data[id].override = null
})
return data
}
/***********
vs. NEW:
***********/
function FB_IN () {
return { _: { menu: { 0: override } } } // menu === 'menu:0'
}
function override (data) {
data._['btn:0/0'] = ([btn]) => btn()
data._['btn:1#small/0'] = ([btn]) => btn()
return data
}
5// ----------------------------------------------------------------------------
// 7. make demo (=`FB_MD`) redo the menu override
// demo.js
/***********
NOW:
***********/
function FB_MD () {
return {
0: { subs: ['app/foo/head/nav/0'] },
// PROBLEM_1: this does **not** work: '0' key will overwrite 0 key
'0': { type: 'menu', override: [override_menu] }
}
}
function override_menu (data) {
// PROBLEM_2: how does this "redo" the original "menu override" from menu default data?
data.menu.items.push('demo')
return data
}
/***********
vs. NEW:
***********/
function FB_MD () {
return { _: { app: { 0: override } } } // app === 'app:0'
}
function override (data) {
data._['foo/head/nav/menu/0'] = ([menu]) => menu()
return data
} There seem to be some issue with your version:
|
Tasks -
|
Tasks -
|
feedback Looks good. I have no opinion yet on whether I didnt understand what or why we need something extra for export/import, ...like a I am not yet super happy with the issue:
|
Tasks -
|
feedback regarding slotsyou answered, but i'm unclear why we need slots at all in the STATE module. I have a feeling we dont. regarding
|
Tasks -
|
feedback slotsOkay, lets ignore slots for now. I think we need to revist them when we finally get to "dataset group mapping and switching" :-) find/searchI didnt entirely understand how this works. In my mind, this can become a simple lookup, where type or path is basically a "unique instance id" and can serve as a key in a key value store to lookup associated data state to be loaded when a module initializes with a non-empty database data/pathyou said it is merged. How does it work and how does it play with other icon overrides defined e.g. in Basically:
Of course, that So we first have to "run" all modules and fallbacks in our head and use the comments to build that hand crafted hard coded expectation in the test script.
|
Tasks -
|
Tasks -
|
feedback feedback for worklog 248Sounds good so far. I need to check the example code how the module is used to really understand some of what you explain, such as: I would have been a bit better i believe, if you had started with the example demo app source code, that runs and initialized one statedb after the next and requires dependencies and so on, all the way down and at each step, you could explain what is already known to the STATE module and what it stores, calculates or internally uses to provide the requested state to the diffrent modules and instances. I feel that way it would be easier for me to follow in which order things execute and when we preprocess and why. Other than that - i would request a bit of refactoring: function statedb (defaults) {
const { api, drive, on, _ } = get_module_data(defaults)
const data = drive
local_state.api = api // local_status.fallback_instance
// ...
}
// button.js
function defaults () {
const drive = {} // inputs, files, css, data stuff
const api = function fallback_instance () {} // module.exports
Object.assign(api, { small: function fallback_instance_small () {} }) // module.exports.small, ...
const on = function (subpath, overrides) { return overrides[0]() }
const _ = {
'foo:0': { $: function module_override () {}, 0: { $: function instance_0_override () {} } }
}
return { drive, api, on, _ }
} Basically to change
for example: The above example refactored would look like: function fallback_module () {
return {
// drive: {},
api: fallback_instance,
// on (subpath, overrides) {},
_: {
"app": {},
}
}
function fallback_intsance () {
return {
drive: {
inputs: {
"page.css": { data: `body { font-family: 'system-ui'; }`
}
},
_: {
"app": {
0: override_app
}
}
}
}
} following the pattern or schema: function fallback () { return { drive, api, on, _ } } comparisonCould you do another kind of refactor by literally making the file the same line by line where it is supposed to be the same?
In these, both version, example and example2 are technically absolutely exatly the same, yet it is written differently, which means when i read through the file its additional confusion. Ideally i can only focus on the lines that are DIFFERENT to see where and why things are different with the different approaches. Could you fix that throughout the file? :-) your explanationthank you for all the explanation, but still, whether it is It is otherwise difficult to follow if you arent yet deeply familiar with the code you wrote - which at this point only you are :-) Also, the "example" and "example2" page.js is ideally the same code, where you would first write the "deep overwrite" version and then copy the code and just comment out the "deep overwrites", so it is easy to spot where the differences are when going through the code myself, which i plan to do after the next worklog with the above changes :-) You do explain the page.js code and the overrides and show the logs in the console, but what is unclear is, in which phase and order STATE module functions get triggered by those overrides to build up the internal cache or state step by step, based on what it already knows and so on .... That would be most important to describe and compare between example and example2 :-) |
Tasks -
|
feedback The longer worklog video (26 minutes) is processed in great detail on discord, but is too much information for a worklog comment here, so rather the processed results of that will be added after the next worklog to save some space here :P But it was a good video, quite informative and definitely lots of progress. Thanks :-) |
@todo
#19
STATE
DB
@output
❓STATE_v0.0.?
The text was updated successfully, but these errors were encountered: