Skip to content
This repository has been archived by the owner on Mar 5, 2018. It is now read-only.

Advanced helpers #62

Closed
topaxi opened this issue Apr 19, 2017 · 1 comment
Closed

Advanced helpers #62

topaxi opened this issue Apr 19, 2017 · 1 comment

Comments

@topaxi
Copy link

topaxi commented Apr 19, 2017

I'm not sure if this makes sense in glimmerland, but it would be nice to have a way to have helpers which can update their own values.

Usecases:
Timers, Observables, Tasks etc. which emit values asynchronously and need to be destroyed after removal.
Manual subscription, timerIds handling can get tedious after a while.

This can obviously be implemented in components, but for attributes/properties this does not seem to be possible.

I'd imagine something like:

export default class SubscribeHelper {
  private sub: Subscription;

  @tracked value: any;

  init(observable: Observable<any>) {
    this.sub = observable.subscribe(v => this.value = v)
  }

  destroy() {
    this.sub.unsubscribe()
  }
}

Usage in template:

<div class={{subscribe currentClass}}>{{subscribe content}}</div>

Inspired by the angular async pipe:
https://angular.io/docs/ts/latest/api/common/index/AsyncPipe-pipe.html

@locks
Copy link
Contributor

locks commented Mar 5, 2018

This repo has been merged with glimmerjs/glimmer.js (into a monorepo setup). I am not sure if this issue is still applicable, but if you could confirm it is still an ongoing concern and open it over there that would be very helpful.

Sorry for the noise, but thank you for your help!

@locks locks closed this as completed Mar 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants