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 31E121FF179 for ; Wed, 29 Oct 2025 14:50:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B3154C36E; Wed, 29 Oct 2025 14:51:22 +0100 (CET) Mime-Version: 1.0 Date: Wed, 29 Oct 2025 14:50:47 +0100 Message-Id: To: "Shannon Sterz" X-Mailer: aerc 0.20.0 References: <20251029133002.236835-1-s.sterz@proxmox.com> In-Reply-To: <20251029133002.236835-1-s.sterz@proxmox.com> From: "Shannon Sterz" X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1761745835170 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.060 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] [RFC yew-comp/yew-widget-toolkit 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" discussed this off-list and was encouraged to also add versions of these helpers for selections in multi-select mode. will include that in a v1. On Wed Oct 29, 2025 at 2:30 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 as 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; > } > ``` > > 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). > > proxmox-yew-widget-toolkit: > > Shannon Sterz (1): > store: add helper methods to extract a record via a selection > > src/state/store.rs | 18 +++++++++++++++++- > 1 file changed, 17 insertions(+), 1 deletion(-) > > > proxmox-yew-comp: > > Shannon Sterz (1): > token panel: use new `selected_record` helper > > src/token_panel.rs | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > > Summary over all repositories: > 2 files changed, 19 insertions(+), 10 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