Add new Partials mode - upsert
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- deno, typescript
- Domain
- frontend
Research direction
Start by reading the partial update implementation and the existing replace, append, and prepend modes; the issue does not name specific files or tests. Decide whether keyed child replacement belongs in a new upsert mode or in the existing modes, then define tests for matching and unmatched keys. Done means the chosen behavior is implemented and verified, but the issue gives no test entry point.
Written by the indexing model from the issue text.
Description
I propose adding an additional mode for partials to complement replace, append, and prepend. At this stage I have called it upsert.
Associated pull request- #2834
It functions similar to append, however each direct child node in the Partial update with a ‘key’ prop is compared to the direct children of the corresponding Partial already in the document. If a match is found, it will swap out that element, otherwise it will append the new node to the existing content.
I believe this has several use cases, the simplest I can think would be a todo list, where individual todo items can be sent to the client to populate a list, or update as they are modified, without using islands or any additional client side JavaScript. Another example, which is my specific use case, is that I need to update a list of recent chats in a messaging app as new messages arrive. Rather than send another copy of the entire list on each update, I can send just the individual item, which would feature an unread message badge. My current work around is using global state to maintain an array of the DOM nodes, and sending that list to the server with every request, in order to determine whether a message is coming from someone already in the recent list or not, so I don’t end up with duplicates.
If adding this additional mode is considered adding unnecessary complexity, then an alternative solution might be that both append and prepend would automatically substitute child nodes if a matching key is detected. Preact warns about having duplicate keys in component children already, but Fresh will currently not check this.
I am happy to take on feedback, both for this feature, as well as the correct etiquette for contributing. I am a solo web developer with absolutely no experience collaborating on projects.
- Dominant language
- TypeScript
- Stars
- 13.8k
- Forks
- 757
- Avg merge
- 3m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from freshframework/fresh
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
freshframework/fresh#3920 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
freshframework/fresh#3833 ·
-
feat
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
freshframework/fresh#3803 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
freshframework/fresh#3918 · 1 comment · 4 reactions ·
-
Tab title doesn't update to <Head> <title> when navigating to a page with another <title>Possibly taken @1AbdullahButt claimed this 7 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 57/100
freshframework/fresh#3916 ·
All issues in freshframework/fresh
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tintinweb/pi-subagents#459 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
danielmiessler/LifeOS#2830 ·
Maintainers usually reply within 6 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
area: client enhancement priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
opensro-dev/opensro#3681 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day