Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:27
    renovate[bot] synchronize #44830
  • 20:27

    renovate[bot] on angular

    build: update angular (compare)

  • 20:10
    fireflysemantics commented #44880
  • 20:09
    chrispang24 starred angular/angular
  • 20:07
    JoostK commented #44880
  • 20:06
    JoostK commented #44880
  • 20:03
    fireflysemantics commented #44880
  • 20:02
    fireflysemantics commented #44880
  • 19:57
    JoostK commented #44880
  • 19:53
    fireflysemantics commented #44880
  • 19:52
    fireflysemantics commented #44880
  • 19:51
    JoostK commented #44880
  • 19:50
    fireflysemantics commented #44880
  • 19:49
    fireflysemantics commented #44880
  • 19:48
    JoostK commented #44880
  • 19:42
    fireflysemantics commented #44880
  • 19:40
    fireflysemantics commented #44880
  • 19:40
    fireflysemantics commented #44880
  • 19:38
    inanemed commented #44880
  • 19:38
    inanemed commented #44880
Rob Wormald
@robwormald
depends what the use case is, generally
Hussain
@hussainb
Right now, I have a global nav component
It has few golbal things like alerts, modals etc
Rob Wormald
@robwormald
@qdouble heh, that's one thing that sort of sucks with typescript.
Hussain
@hussainb
I just need need to customize their behavior from different components
Rob Wormald
@robwormald
or just do window['whatever'] = whatever
@hussainb i'd probably use DI to do this, if its configuration type stuff
Hussain
@hussainb
no not config
Take an example, I need to show plain alerts, but need to change the text between diffenernt components
Rob Wormald
@robwormald
[bindings] are fine then
Hussain
@hussainb
So, I pass a callback having the alert its own text and fire the callback when an input on the nav component is clicked
yes
Rob Wormald
@robwormald
yeah, that would be better served with (click)
Hussain
@hussainb
yep
Rob Wormald
@robwormald
not [somefuncitontobecalled]
Hussain
@hussainb
Oh ok
Rob Wormald
@robwormald
properties go in with [bindings]
events come out with (eventName)
Hussain
@hussainb
ok
Rob Wormald
@robwormald
also, for stuff like an alert, you're better to use a service to control it
Hussain
@hussainb
oh, true
Zahadi Eslicho
@panKt

Let’s say I'll put some data into route that will show that this route needs auth.
Is there some global way to intercept navigation to that route and
1) Find out if that route needs an auth
2) Redirect to login page if there is no auth
3) Of course component that represents that route should not be created if there is no auth
3) View should not be rendered if there is no auth

@CanActivate can do similar thing, but it needs to be added on components. I'm looking for a way to avoid that copy-paste on every component

Hussain
@hussainb
I will look into using a service instead.
Anthony
@qdouble
@robwormald thanks, ['whatever'] does the job just fine
Rob Wormald
@robwormald
Hussain
@hussainb
@robwormald , OK, looking at it
Oh, this is the alert service!
Rob Wormald
@robwormald
so the service is injected into the component, and then you can also inject it into any other component or service
Hussain
@hussainb
Yes!
@robwormald, ThankYou!
Anthony
@qdouble

@robwormald one last bit of functionality, there's also this command

grecaptcha.reset(
opt_widget_id
)

Just in case you need to reset captcha, for instance if the person has completed the captcha but still entered in the wrong password. So I'm assuming you'd need to pass that command from the component into the directive? How would do we go about that?

Rob Wormald
@robwormald
in reality i'd probably wrap up most of the captcha stuff into an injectable service
and inject that into your captcha component
Anthony
@qdouble
the service would be shared between the component and the directive?
Rob Wormald
@robwormald
right. it would allow you to "remote control" the captcha
like the alert service plunk above ^
Anthony
@qdouble
gotcha, will look into that now
Hussain
@hussainb
@robwormald deserves an xmas present
Oleg Korsak
@kamikaze
is there a way to prevent following code to make a request while previous is not completed (except manuall semaphore mess)? Not only prevent it but also all parallel callers must receive the same observer. Tried to use ReplaySubject and .share() with no luck. Any ideas?
signin(login:string, password:string):Observable {
    var data = {
      login: login,
      password: password
    };

    return this.http.put('/api/v1/auth', JSON.stringify(data))
      .map(res => res.json());
  }
Rob Wormald
@robwormald
@kamikaze that's sort of the wrong way to think about it. the first question would be - why is it making multiple requests? are you queuing them up or?
presumably you're getting a token or something for further requests?
Oleg Korsak
@kamikaze
@robwormald it may be long request-response while user clicks "signin" button again and again
it's not a way to think, it's a reality :)
Rob Wormald
@robwormald
well the first thing i'd do would be disable the damn button :)
Oleg Korsak
@kamikaze
sure but I just want to make sure that this request is kinda "singleton"
Rob Wormald
@robwormald
that's why i was asking about how you're structuring this - presumably you're going to:
  • naviate to a login page
  • click signin
  • wait for response