Restructuring a super call in a constructor to use the 'this'

Discussão em 'Angular' iniciado por st_clair_clarke, Janeiro 25, 2025.

  1. I have the following service:

    import {
    ENVIRONMENT_TOKEN
    } from '@reg/environment/domain'

    @Injectable({ providedIn: 'root' })
    export class RegStore extends ImmutableStore<TRegState> {
    #env = inject(ENVIRONMENT_TOKEN)
    constructor() {
    super({
    name: 'RegistrationStore',
    mutationProducerFn: produce as unknown as MutationFn<TRegistrationState>,
    initialState: new RegState(),
    plugins: [
    // this.#env.signalStoryStorePlugins ERROR 'this' call cannot be used before 'super'
    useStorePersistence({
    persistenceKey: 'RegStore',
    persistenceStorage: localStorage,

    }),
    ]
    })
    }

    store: Immutable<TRegState> = this.state()

    }



    How could the call - this.#env be restructured to remove the error?

    Continue reading...

Compartilhe esta Página