ayo,
@ayo@ayco.io avatar

Thinking of an attachEffect function to attach a callback to property changes :)

class Counter extends WebComponent {  
 static properties = ["count"];  
 onInit() {  
 this.props.count = 0;  
 this.onclick = () => ++this.props.count;  
 attachEffect(this.props.count, () => console.log("value changed!"));  
 }  
 get template() {  
 return `<button>${this.props.count}</button>`;  
 }  
}  
demivan,
@demivan@fosstodon.org avatar

@ayo Why not call it watch?

ayo,
@ayo@ayco.io avatar

@demivan Hmm is there a similar API that calls it watch? I will check if there is…

demivan,
@demivan@fosstodon.org avatar

@ayo It looks like Vue watch/watchEffect

ayo,
@ayo@ayco.io avatar

@demivan Ahh okay, thanks! Full disclosure, I’m not a vue developer so I miss a lot of the terminology… first time I wrote vue was for elk 🤣

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • GTA5RPClips
  • provamag3
  • ethstaker
  • cisconetworking
  • tester
  • modclub
  • everett
  • cubers
  • tacticalgear
  • Leos
  • megavids
  • normalnudes
  • anitta
  • JUstTest
  • lostlight
  • All magazines