-
Notifications
You must be signed in to change notification settings - Fork 1
Programming Guidelines
theRealProHacker edited this page Feb 27, 2023
·
1 revision
State Management is a difficult topic. Most programs will (eventually) need global or at least shared state.
In Positron, you are responsible for state management yourself. But I have some tips that might help you.
Let's say you have a list of names that you want to show. You could hold a global list and update the DOM whenever it is changed. But you could also save the list in the DOM and then you don't need the global list anymore. For this the data attributes come in handy. Any attributes of objects you don't want the user to see, you can put into data attributes. You can access these like so:
-
SingleJ(query).data(key)
to get thekey
attribute -
SingleJ(query).data(key, value)
to set thekey
attribute tovalue