当前位置:网站首页>Swiftui view onReceive method receives "redundant" event resolution
Swiftui view onReceive method receives "redundant" event resolution
2022-07-27 20:40:00 【Giant panda Hou Pei】

summary
As we all know ,SwiftUI It provides us with convenient onReceive Modifier method , To receive events sent by external publishers .
But in some cases , We need to shield some irrelevant “ redundancy ” event .
such as ,SwiftUI Medium Picker The publisher corresponding to the bound value , It's always there Picker Send an event when creating , This is what we don't want :

As shown above ,Picker Views can be created by users on demand , But every time it is created, it will send a change event of the binding property .
How to avoid receiving this “ It's useless ” What about the incident ?
Actually , Just a small change in the code , We can fix this problem perfectly !
Let’s go!
Source code reproduction
The relevant source code is as follows :
@objc(BSUToday)
public 边栏推荐
- [RCTF2015]EasySQL-1|SQL注入
- 最新获得淘宝app商品详情原数据 的API
- MySQL 日志查询日志
- A layered management method of application layer and hardware layer in embedded system
- Common ways to keep requests idempotent
- What app should individuals use for stock speculation to be safer and faster
- Office automation solution - docuware cloud is a complete solution to migrate applications and processes to the cloud
- Set -- data deconstruction
- Passive income: return to the original and safe two ways to earn
- es6删除对象的属性_ES6删除对象中的某个元素「建议收藏」
猜你喜欢
![[deep learning] video classification technology sorting](/img/bf/422d4ef342199966bbdaae06977699.png)
[deep learning] video classification technology sorting

PyQt5快速开发与实战 4.3 QLabel and 4.4 文本框类控件

【效率】弃用 Notepad++,这款开源替代品更牛逼!

PyQt5快速开发与实战 4.5 按钮类控件 and 4.6 QComboBox(下拉列表框)

If you want to switch to software testing, you should pass these three tests first, including a 3000 word super full test learning guide

Jetpack Compose 性能优化指南——编译指标

Can software testing be learned in 2022? Don't learn, software testing positions are saturated

【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...

2022.07.11

图解LeetCode——剑指 Offer II 115. 重建序列(难度:中等)
随机推荐
软件测试面试题:已知一个数字为1,如何输出“0001
我也是醉了,Eureka 延迟注册还有这个坑
(manual) [sqli labs38, 39] stack injection, error echo, character / number type
ES6--解构赋值
[Alibaba security × ICDM 2022] 200000 bonus pool! The risk commodity inspection competition on the large-scale e-commerce map is in hot registration
继华为、联发科之后,这家手机芯片厂商宣布向武汉捐款700万
华为150人团队驰援,武汉“小汤山”5G基站火速开通!
Can software testing be learned in 2022? Don't learn, software testing positions are saturated
Introduction to zepto
You can understand it at a glance, eslint
Codeworks round 810 (Div. 2) B.Party super detailed problem solution
Express: search product API by keyword
A layered management method of application layer and hardware layer in embedded system
Built in functions other functions
IE11 下载doc pdf等文件的方法
Graphic leetcode - Sword finger offer II 115. reconstruction sequence (difficulty: medium)
EasyCVR平台关闭录像为何还会有TS切片文件生成?
API for obtaining the latest raw data of Taobao app product details
【阿里安全 × ICDM 2022】20万奖金池!大规模电商图上的风险商品检测赛火热报名中!...
leetcode:1498. 满足条件的子序列数目【排序 + 二分 + 幂次哈希表】