3

I wrote a very detailed answer within the last 24 hours and I can't find it anymore.

I found a couple of future bugs inside the code of the OP's question. I explained them and how to fix them. It wasn't intended to be the primary solution to the question, but it was important and it took me some time to write it.

Can anyone check it?

11
  • 1
    Yes it's possible that your answer is deleted and you weren't notified about it. Oct 20, 2016 at 11:32
  • Stackoverflow is a Q&A code and bugs websites. I request to undelete it.
    – Stav Alfi
    Oct 20, 2016 at 11:33
  • 1
    I am assuming you are talking about this: stackoverflow.com/questions/40136595/… - which you won't be able to see, as the question OP deleted it, with this comment on your answer: "Thank you for the answer, but I've got _zone_symbol__state: null anyway"
    – Oded
    Oct 20, 2016 at 11:34
  • Did you mean that the question removed?
    – Stav Alfi
    Oct 20, 2016 at 11:42
  • 5
    Yes, the question's author has deleted it. They can do this as long as there's only one answer and it has no upvotes, to avoid losing valuable content. Also note that "This may not be the answer to your question" isn't a confidence-inspiring start to an answer. If you feel the need to put that in bold, maybe ask for further information before answering?
    – jonrsharpe
    Oct 20, 2016 at 11:51
  • @jonrsharpe Thanks its a good idea. I would like to have the content of my answer somehow for a future post/presonal content to my computer. How can I get it?
    – Stav Alfi
    Oct 20, 2016 at 11:57
  • 1
    But don't you already know it? You wrote it! Also, according to the prefix and postfix, you knew it wouldn't be much use when you did so.
    – jonrsharpe
    Oct 20, 2016 at 11:58
  • I guess you didnt undersatnd what I asked - can you help me get the content of my answer?
    – Stav Alfi
    Oct 20, 2016 at 12:04
  • 1
    @StavAlfi Here is a pastebin of the markdown of your answer: pastebin.com/8qu2w24n (From the revision of your answer: stackoverflow.com/posts/40137311/revisions)
    – Rizier123
    Oct 20, 2016 at 12:08
  • @StavAlfi "Is it possible to remove an answer without notifing the one who wrote the answer?" is very different from "can you help me get the content of my answer?" - I'm not sure how one could have figured what you wanted from what you've wrote. Explicit request to recover content would be more appropriate if it is only thing you were looking for. Oct 20, 2016 at 17:11
  • @Alexei Levenkov Oded wrote that the OP removed the question and answer my question I added addional request to get my answer. I did not write it in the question,
    – Stav Alfi
    Oct 20, 2016 at 17:24

1 Answer 1

8

The OP deleted the whole question, including your answer:

This may not be the answer to your question but it is an imporovment/fixing a future bug(?) to your first method.

The problems:

  1. You subscribe inside the promise but don't unsubsribe after so you will get unexpected behavior after the promise resolved successfully.
  2. I guess you are expecting the subsription at the first time will happen befor the promise resolved but it may not be the case here. You need to insure that by your self.

The solution:

usign the take(1) and toPromise() methods of rxjs: 1. take(1) - if this.usersService.checkEmail(control.value) will never complete (maby a firebase subscription), use take(1) to inforce it to complete.

  1. toPromise() - "cast" it to promise so you can return what u need and most importent, insure that what is inside happens befor the promise resolved.

Note: If you won't add take(1) but only toPromise(), your promise will never be resolved and what inside will never be called incase the observable will never complete.

Code:

emailTaken(control: Control): Promise<ValidationResult> {
    return this.usersService.checkEmail(control.value)
      .take(1)
      .toPromise()
      .then(res=>....);
  }

I hope I'm wrong and this was the behavior you wanted to get in the first place. Incase you didn't here is a better way. There is no need to accept this as an answer.

Please note that if you have to prefix and suffix your answer with such caveats, you should just not post it.

9
  • Thanks. Why cant a user who answered some question, cant see it in his profile? Even if the question removed by someone else? (Why I your help to see my answers?)
    – Stav Alfi
    Oct 20, 2016 at 12:13
  • @StavAlfi because you don't have enough rep to see deleted questions. I believe you can see your own deleted questions, and your deleted answers on questions that haven't been deleted.
    – jonrsharpe
    Oct 20, 2016 at 12:14
  • @NathanOliver but I think they still won't be able to actually click through and see the answer, as the whole question's deleted
    – jonrsharpe
    Oct 20, 2016 at 12:15
  • @jonrsharpe Yeah. Comment removed. trying to find the FR to get this feature. Oct 20, 2016 at 12:18
  • This makes no sense. I feel that I wasted my time to write a content that I have no access to.
    – Stav Alfi
    Oct 20, 2016 at 12:23
  • 2
    @StavAlfi had your answer got any upvotes in the four hours between it being posted and the OP deleting their question, they wouldn't have been able to do so. The fact of the matter is that it wasn't a useful answer to the question, so you did waste your time.
    – jonrsharpe
    Oct 20, 2016 at 12:26
  • @StavAlfi you've explicitly decided to post non-answer - so at that point you thought it is good/interesting idea. One should expect downvotes/deletion on non-answers. So presumably you got your entertainment value out of the post when you wrote it and should just write that time of. This is similar to going to casino and later complaining that you've lost money (instead of boasting) :) Oct 20, 2016 at 17:59
  • Hi @Alexei Levenkov consider reading my asnswer befor respoding. I found a bug in his code and I reported to him about that. there is no "entertainment" here
    – Stav Alfi
    Oct 21, 2016 at 1:59
  • @StavAlfi if you don't find answering questions entertaining on its own you may soon realize that SO is a very thankless place. I don't know what your reasons for participation are, but if you are not interested in process of answering you may want to find some other way to spend your time - documentation seem to have different model, or just writing blog posts somewhere else. Oct 21, 2016 at 3:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .