From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id B5C971FF16B for ; Fri, 21 Nov 2025 17:17:47 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7A36327658; Fri, 21 Nov 2025 17:17:55 +0100 (CET) Mime-Version: 1.0 Date: Fri, 21 Nov 2025 17:17:52 +0100 To: "Shannon Sterz" Message-Id: X-Mailer: aerc 0.20.0 References: <20251121161423.390869-1-s.sterz@proxmox.com> In-Reply-To: From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763741840274 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.080 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [yew-devel] Superseded: Re: [PATCH yew-comp/yew-widget-toolkit v3 0/2] add helpers to get a record via a Selection from a Store X-BeenThere: yew-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Yew framework devel list at Proxmox List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Yew framework devel list at Proxmox Cc: yew-devel@lists.proxmox.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: yew-devel-bounces@lists.proxmox.com Sender: "yew-devel" On Fri Nov 21, 2025 at 5:15 PM CET, Shannon Sterz wrote: > Superseded-by: https://lore.proxmox.com/yew-devel/20251121161423.390869-1-s.sterz@proxmox.com/ ignore this, this is still the current version of this patch series... i replied to the wrong email there... > On Fri Nov 21, 2025 at 5:14 PM CET, Shannon Sterz wrote: >> a very common pattern is to use a `Store` combined with a `Selection`. >> however, to get the record from a `Store` that has the same `Key` as is >> selected by the `Selection` is a little cumbersome. it requires >> dealing with several optional values. so many components implement a >> helper for that. it usually looks like this: >> >> ```rust >> fn get_selected_record(&self) -> Option { >> self.selection >> .selected_key() >> .and_then(|key| self.store.read().lookup_record(&key).cloned()) >> } >> >> let Some(record) = self.get_selected_record() else { >> return false; >> } >> ``` >> >> to avoid duplicating this effort in every such component add new helper >> methods to the `Store`. they each take a `Selection` and either return >> an optional reference or an optional clone of the selected record. >> turning the above into: >> >> ```rust >> let Some(record) = self.store.selected_record(&self.selection) else { >> return false; >> } >> ``` >> >> there are also helpers that are prefixed with `multi_` to help deal with >> `Selection`s in multi-select mode by returning a vector of all selected >> entries. >> >> the second commit in this series is mostly for demonstrative purposes. >> sending this as an rfc as i am not sure if the naming of these functions >> is ideal or whether we want to add both helpers (instead of just one of >> them). >> >> Changelog >> --------- >> >> changes since v2: >> >> * rebase on current master. >> >> changes since v1: >> >> * rebase on current master. >> * add helpers for multi selections too. >> >> proxmox-yew-widget-toolkit: >> >> Shannon Sterz (1): >> store: add helper methods to extract a record via a selection >> >> src/state/store.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 48 insertions(+), 1 deletion(-) >> >> >> proxmox-yew-comp: >> >> Shannon Sterz (1): >> token panel: use new `selected_record` helper >> >> src/token_panel.rs | 10 ++-------- >> 1 file changed, 2 insertions(+), 8 deletions(-) >> >> >> Summary over all repositories: >> 2 files changed, 50 insertions(+), 9 deletions(-) >> >> -- >> Generated by git-murpp 0.8.1 _______________________________________________ yew-devel mailing list yew-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel