Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offer @Decorator usage for events #77

Open
bennsm opened this issue Feb 23, 2023 · 2 comments
Open

offer @Decorator usage for events #77

bennsm opened this issue Feb 23, 2023 · 2 comments
Labels
domain: networking Related to the Networking flamework module enhancement New feature or request feedback needed A request of feedback, use cases, etc from any who may be interested in this issues.

Comments

@bennsm
Copy link

bennsm commented Feb 23, 2023

current required code:

runEvent(){
    // handle event
}

onStart() {
        Events.testEvent.connect(() => {
            this.runEvent()
        });
       // other code
}

potential required code:

@testEvent()
runEvent(){
    // handle event
}

onStart(){
    // other code
}

it's so much cleaner

@bennsm bennsm changed the title offer @Decorator support for events offer @Decorator usage for events Feb 23, 2023
@Fireboltofdeath Fireboltofdeath added enhancement New feature or request domain: networking Related to the Networking flamework module feedback needed A request of feedback, use cases, etc from any who may be interested in this issues. labels Feb 23, 2023
@ghost
Copy link

ghost commented Aug 31, 2023

That's a really cool idea, it would be cool to see it added!

The decorator should be applied to components or services and have maid task automatically given to the connection.

@Component({})
export class TimeGui extends BaseComponent {

	@Connect(workspaceAttribs.getChangedSignal('TimeLeft')) // support for every signals
	private updateTime() {
		this.instance.Text = tostring(workspaceAttribs.get('TimeLeft'))
	}

}

@Fireboltofdeath
Copy link
Member

That's a really cool idea, it would be cool to see it added!

The decorator should be applied to components or services and have maid task automatically given to the connection.

@Component({})
export class TimeGui extends BaseComponent {

	@Connect(workspaceAttribs.getChangedSignal('TimeLeft')) // support for every signals
	private updateTime() {
		this.instance.Text = tostring(workspaceAttribs.get('TimeLeft'))
	}

}

This is for @flamework/networking and not signals. Something like that would be out of scope for Flamework and could be implemented using the modding API or a custom decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: networking Related to the Networking flamework module enhancement New feature or request feedback needed A request of feedback, use cases, etc from any who may be interested in this issues.
Projects
None yet
Development

No branches or pull requests

2 participants