ct-js / ct-js-old

⚠️ Old repository of ct.js app. New repository here: https://github.com/ct-js/ct-js
https://ctjs.rocks/
MIT License
1.69k stars 131 forks source link

Tidy up window.signals name and enforce a policy on listeners' names #214

Closed CosmoMyzrailGorynych closed 2 years ago

CosmoMyzrailGorynych commented 4 years ago

Tidy up the mess with global event listeners, aka window.signals. There should be a logical and obvious naming system, an accessible list of names of existing events, and triggers set up on generic asset changes and UI events.

window.signals (WIP)

Intention of window.signals

window.signals must only be used to update views of directly edited entities and those entities that use others as is. For example,

But also consider this:

Asset viewers must not patch their assets by themselves due to changes in dependencies.

Handling changes coming both from a user and dependency hooks

Users may be editing an asset that gets patched by a hook that resolves missing asset dependencies. Before making patches, window.orders.trigger('saveAsset') is called to forcefully save an asset if it is opened in an asset viewer.

Operations upon assets

These events must be triggered only from the node_requires/resources directory. All the CRUD logic also lies here.

For each asset type, these events must be generated (using texture as an example here):

These events are for updates between different entities. Any asset type also emits these events:

These events are mainly for the asset viewer. All the events pass two arguments: the changed js object and a path to an asset file. assetRenamed also passes the old path as its third argument.

Move operations are counted as assetRenamed.

UI events

window.orders (WIP)

While window.signals is used for read-only operations in UI, window.orders may be used to forcefully trigger some events in asset editors.

stale[bot] commented 2 years ago

Hey there 👋 I marked this issue as stale as it hadn't brought much attention for quite a while. I do understand that stale issues are still issues, yet here stale issues receive the least attention from maintainers so they can focus on more relevant tasks. You can help with this issue by checking whether it affects latest versions of ct.js and writing about it if it does, providing an example project and steps to reproduce. Or maybe you can close it with a PR! Note that some platform-dependent issues can't be resolved by developers due to the absense of such devices :c We will need help from you for such tasks. If this issue won't get attention in three months, it will be closed.

stale[bot] commented 2 years ago

This issue is now closed! Please create a new one with a proper template if this issue still affects ct.js.