anywhichway / generx

JavaScript generators extended with forEach, map, reduce ... most standard Array methods.
MIT License
14 stars 1 forks source link

reset is not a function #4

Open ilDeffo opened 1 year ago

ilDeffo commented 1 year ago

Hi, I don't understand how to reset the generator from an external file. I want the generator to be reset when the user logs out from my app. Here's my code, I hope my question becomes more clear:

generator.js:

function* generator(param1, param2) {
  // do stuff...
}

generator = generx(generator)
export { generator }

otherFile.js:

import { generator } from 'generator.js'
export function logout() {
    generator.reset()
}

But when I call logout(), I obtain generator.reset is not a function . I also tried to use generator().reset() and I don't have any errors but the generator is not really reset. How do I have to change the code to make it work?

anywhichway commented 1 year ago

Have you first tried doing this without an external file, i.e. just putting your code in line?

Sent from my T-Mobile 5G Device Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Federico De Falco @.> Sent: Tuesday, September 27, 2022 12:53:20 AM To: anywhichway/generx @.> Cc: Subscribed @.***> Subject: [anywhichway/generx] reset is not a function (Issue #4)

Hi, I don't understand how to reset the generator from an external file. Here's my code, I hope my question becomes more clear:

generator.js:

function* generator(param1, param2) { // do stuff... }

generator = generx(generator) export { generator }

otherFile.js:

import { generator } from 'generator.js' export function f() { generator.reset() }

But when I call f(), I obtain generator.reset is not a function . I also tried to use generator().reset() and I don't have any errors but the generator is not really reset. How do I have to change the code to make it work?

— Reply to this email directly, view it on GitHubhttps://github.com/anywhichway/generx/issues/4, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABF2US4RR2UQVKLBLKJRN5TWAKRXBANCNFSM6AAAAAAQWQHQCI. You are receiving this because you are subscribed to this thread.Message ID: @.***>