rbxts-flamework / core

Flamework is an extensible game framework. It requires typescript and offers many useful features.
MIT License
113 stars 8 forks source link

Flamework eagerly constructs components ignoring predicate #115

Closed xethlyx closed 4 weeks ago

xethlyx commented 1 month ago
import type { Components } from '@flamework/components';
import { BaseComponent, Component } from '@flamework/components';
import type { OnStart } from '@flamework/core';
import { Service } from '@flamework/core';
import { Workspace } from '@rbxts/services';

interface Attributes {}

@Component({
    tag: 'Test',
    predicate: () => false,
})
export class MyComponent extends BaseComponent<Attributes> {
    constructor() {
        super();
        print('i was constructed');
    }
}

@Service({})
export class Test implements OnStart {
    constructor(private readonly components: Components) {}

    onStart() {
        const part = new Instance('Part');
        part.Parent = Workspace;
        part.AddTag('Test');
        this.components.getComponent<MyComponent>(part);
    }
}

This results in i was constructed being output, despite predicate always returning false

Fireboltofdeath commented 4 weeks ago

Fixed in https://github.com/rbxts-flamework/components/commit/07ae23a7cf5bb53cc3ba97b44f75fe2f51719496