0

Will attach full example of this task mock.js unsubscribe. I have a store reducer (tbodyCommand.reducer.js) that needs to take 10 rows from data by subscribing it and than after that it have to be unsubscribed. I am using standard .unsubscribe() method, but it goes to TypeError _mock.default.unsubscribe is not a function. How can i turn off my subscribing?

I found similar question over here unsubscribe is not a function on an observable where main problem appears in RxJS version but mine seems to work good for me. The example of syntax construction over here with subscribe method doesn't contain any way to deal with mock.js; How can I use it in my example so it will work? Is there any other ways to come to this problem simpler?

method

Zak the Gear
  • 131
  • 2
  • 14

1 Answers1

0

Got changed properties$.subscribe to variable and took out return from subscribe function.

var row_temp = [];

const makeTbodyArray = () => {
  properties$.subscribe((data) => { // this stuff need to go in variable
    if (row_temp.length < 11) {
      row_temp.push(data);
    } else {
      properties$.unsubscribe();
      return row_temp;              // taking out return
    }
  });
};

to

var row_temp = [];

const makeTbodyArray = () => {
  let subscription = properties$.subscribe((data) => {
    if (row_temp.length < 11) {
      row_temp.push(data);
    } else {
      subscription.unsubscribe();
    }
  });
  return row_temp;                 // like that
};
Zak the Gear
  • 131
  • 2
  • 14