webxdc/pixel
16
4
Fork
You've already forked pixel
1

reduce number of terms, helper functions and make docs and variable naming consistent #7

Merged
hpk merged 3 commits from hpk/streamlining into main 2024年02月13日 16:17:01 +01:00
Owner
Copy link

overall has 35 lines less than before which i think is a win for an example.

overall has 35 lines less than before which i think is a win for an example.
@ -94,4 +71,2 @@
} = update.payload;
// incoming Lamport timestamps should always be positive integers.
// ignoring non-comforming updates makes that a guarantee.
Author
Owner
Copy link

with webxdc there is no chance of "non-confirming" updates.
current guarantee is that an app will always see exactly what it is sending, there are never "old" clients or compatibility issues. But i wouldn't explain that here, and simply do no validation whatsoever.

with webxdc there is no chance of "non-confirming" updates. current guarantee is that an app will always see exactly what it is sending, there are never "old" clients or compatibility issues. But i wouldn't explain that here, and simply do no validation whatsoever.
Contributor
Copy link

I initially added the validation while I was working on my PR because updates sent from an earlier version of the app (testing with webxdc-dev) produced some weird results. I think it was something with the greatest timestamp being set to a weird value early on, with subsequent addition and Math.max operations producing NaN somehow, and that being serialized as null in the update.

Restarting webxdc-dev entirely wiped the history so only updates from the new client version were loaded, but having that type check there made it such that any temporary tweaks while prototyping/refactoring would not put it back into a bad state. I figured that anyone looking to fork the app and add new features might run into something similar, so I left it in.

Aside from that, the overhead is negligible and has the benefit of protecting against malicious/mischevous behaviour in case anyone wants to embed the app in a platform with slightly different guarantees or social context (like a web platform with people who trust each other somewhat less than a friendly chat group).

I don't feel strongly about keeping either the validation or the comment, as I agree that the complexity may be more than a beginning developer is able to process. I just want to provide some of the context behind its inclusion.

I initially added the validation while I was working on my PR because updates sent from an earlier version of the app (testing with `webxdc-dev`) produced some weird results. I think it was something with the greatest timestamp being set to a weird value early on, with subsequent addition and `Math.max` operations producing `NaN` somehow, and that being serialized as `null` in the update. Restarting `webxdc-dev` entirely wiped the history so only updates from the new client version were loaded, but having that type check there made it such that any temporary tweaks while prototyping/refactoring would not put it back into a bad state. I figured that anyone looking to fork the app and add new features might run into something similar, so I left it in. Aside from that, the overhead is negligible and has the benefit of protecting against malicious/mischevous behaviour in case anyone wants to embed the app in a platform with slightly different guarantees or social context (like a web platform with people who trust each other somewhat less than a friendly chat group). I don't feel strongly about keeping either the validation or the comment, as I agree that the complexity may be more than a beginning developer is able to process. I just want to provide some of the context behind its inclusion.
@ -117,2 +82,3 @@
// ensure convergence with an arbitrary but deterministic tie-breaker:
// taking the larger of the two values is sufficient for integers
setPixel(offset, Math.max(pixels[offset], enabled), seqnum);
pixels[offset] = Math.max(pixels[offset], value);
Author
Owner
Copy link

think it's not worth an indirection via a setPixel function.

think it's not worth an indirection via a `setPixel` function.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
webxdc/pixel!7
Reference in a new issue
webxdc/pixel
No description provided.
Delete branch "hpk/streamlining"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?