These are chat archives for canjs/canjs

4th
Jan 2018
Leland Kwong
@Leland-Kwong
Jan 04 2018 22:47
I noticed an issue in the 'can-ndjson-stream' example
where this code:
    let read;
    exampleStream.getReader().read().then(read = (result) => {
      if (result.done) return;

      console.log(result.value);
      exampleStream.getReader().read().then(read);

    });
would throw an error about accessing a locked stream.
To fix it we just need to store an instance of the reader once:
    let read;
    const reader = exampleStream.getReader();
    reader.read().then(read = (result) => {
      if (result.done) return;

      console.log(result.value);
      reader.read().then(read);

    });
Chasen Le Hara
@chasenlehara
Jan 04 2018 23:05
Good catch @Leland-Kwong! If you want to submit a PR to fix it, there’s an Edit on GitHub link on each page that makes it really easy to make a fork and submit a PR. :D