refactor(port-generator): now using computedRefreshable
This commit is contained in:
		
							parent
							
								
									165dc93f83
								
							
						
					
					
						commit
						f6237376e1
					
				| @ -11,19 +11,13 @@ | |||||||
| </template> | </template> | ||||||
| 
 | 
 | ||||||
| <script setup lang="ts"> | <script setup lang="ts"> | ||||||
|  | import { computedRefreshable } from '@/composable/computedRefreshable'; | ||||||
| import { useCopy } from '@/composable/copy'; | import { useCopy } from '@/composable/copy'; | ||||||
| import { ref } from 'vue'; |  | ||||||
| import { generatePort } from './random-port-generator.model'; | import { generatePort } from './random-port-generator.model'; | ||||||
| 
 | 
 | ||||||
| const port = ref(''); | const [port, refreshPort] = computedRefreshable(() => String(generatePort())); | ||||||
| 
 | 
 | ||||||
| const { copy } = useCopy({ source: port, text: 'Port copied to the clipboard' }); | const { copy } = useCopy({ source: port, text: 'Port copied to the clipboard' }); | ||||||
| 
 |  | ||||||
| function refreshPort() { |  | ||||||
|   port.value = String(generatePort()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| refreshPort(); |  | ||||||
| </script> | </script> | ||||||
| 
 | 
 | ||||||
| <style lang="less" scoped> | <style lang="less" scoped> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user