Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
Kluskey committed Oct 22, 2024
1 parent 7426378 commit 726f0d0
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,22 @@ export const SpaceEngineNonGameProvider = ({ children }) => {
const observer = new Observer(observerData)

// handle changes/updates to entity
// DO NOT use RTK/Redux here; it manages itself separately. Took a lot of hours trying to figure out a solution: it's much easier just to decouple it so that Redux observes the inputs instead of reacting to this Observer system
// DO NOT update RTK/Redux here; it manages itself separately. Took a lot of hours trying to figure out a solution: it's much easier just to decouple it so that Redux "observes" the playcanvas app & makes changes instead of updates getting "pushed" from the Observer. This is doubly good with separation of concerns because the PlayCanvas app shoulnd't know Redux exists.
observer.on('*:set', async (path, value) => {
// const entityId = extractEntityIdFromJsonPathForObserverStructure(path)
// TODO: try out key compare here to reduce calls to update engine, if needed. benchmark
// console.log('path', path)
// console.log('value', value)
// console.log('json', )
const jsonData: DatabaseEntity = observer.json() as DatabaseEntity
const entityId = jsonData.id

const engineEntity = app.root.findByGuid(entityId)

if (engineEntity) {
console.log('find: engine entity', engineEntity)
}

// const currentData = observer.get(id)
// const updatedData = observer.get();
// updateEngineApp(updatedData);
Expand Down

0 comments on commit 726f0d0

Please sign in to comment.