vue-requests icon indicating copy to clipboard operation
vue-requests copied to clipboard

Component/Directive for v-if="now < start_at"

Open carcinocron opened this issue 7 years ago • 6 comments

I made an issue in this repo, but the author might consider it outside the scope of the library: https://github.com/brockpetrie/vue-moment/issues/24 I'm not requesting "technically how to do it", I'm requesting a clean interface for it.

<div v-if="moment().isBefore(otherTime)"></div><div v-else></div>

It would be awesome if we had something for this, except at the moment of inflection (when moment().isBefore(otherTime)'s status changes from true to false) Vue is able to detect it as a change and react accordingly.

Here is a similar discussion, but did not provide a clean API for accomplishing this. https://github.com/vuejs/Discussion/issues/214

Another possible implementation:

<div v-if="now > otherTime" v-recalculate-at="otherTime"></div><div v-else></div>

where v-reset-now-at="otherTime" might translate to:

resetNowAtDirective:function(){
    this.now = Date.now();
    setTimeout(()=>{
        // triggers mutation observation
        this.now = Date.now();
    },calculate_ms_delay_until(this.otherTime));
},

carcinocron avatar Dec 07 '16 15:12 carcinocron