rbxts-knit's People
rbxts-knit's Issues
Signal.Is is saying its nil
TableUtil.Shuffle type returns void rather than the new shuffled table
Infinite yield possible on 'ReplicatedStorage.rbxts_include.node_modules.knit.Knit:WaitForChild("Services")'
Whenever trying to import knit I get that error
Server:
import { KnitServer as Knit, Signal, RemoteProperty, RemoteSignal } from "@rbxts/knit";
import { Players } from "@rbxts/services";
declare global {
interface KnitServices {
CurrencyService: typeof CurrencyService;
}
}
const CurrencyService = Knit.CreateService({
Name: "CurrencyService",
// Server-exposed signals/fields:
MoneyPerPlayer: new Map<Player, number>(),
MoneyChanged: new Signal<(player: Player, money: number) => void>(),
Client: {
// Client exposed signals:
MoneyChanged: new RemoteSignal<(money: number) => void>(),
GiveMeMoney: new RemoteSignal<() => void>(),
// Client exposed GetMoney method:
GetMoney(player: Player) {
return this.Server.GetMoney(player);
},
},
// Add Money:
AddMoney(player: Player, amount: number) {
let money = this.GetMoney(player);
money += amount;
this.MoneyPerPlayer.set(player, money);
if (amount !== 0) {
this.MoneyChanged.Fire(player, money);
this.Client.MoneyChanged.Fire(player, money);
}
},
SetMoney(player: Player, amount: number) {
this.MoneyPerPlayer.set(player, amount);
this.MoneyChanged.Fire(player, amount);
this.Client.MoneyChanged.Fire(player, amount);
},
// Get Money:
GetMoney(player: Player) {
const money = this.MoneyPerPlayer.get(player);
return money ?? 0;
},
// Initialize
KnitInit() {
print("CurrencyService KnitInit");
const rng = new Random();
this.Client.GiveMeMoney.Connect((player) => {
const money = rng.NextInteger(0, 10);
this.AddMoney(player, money);
print(`Gave ${player.Name} ${money} money`);
});
Players.PlayerRemoving.Connect((player) => this.MoneyPerPlayer.delete(player));
},
});
export = CurrencyService;
Client:
import { KnitClient as Knit } from "@rbxts/knit";
const MoneyService = Knit.GetService("CurrencyService");
function MoneyChanged(money: number) {
print("My money:", money);
}
// Get money and listen for changes:
const initialMoney = MoneyService.GetMoney();
MoneyChanged(initialMoney);
MoneyService.MoneyChanged.Connect(MoneyChanged);
// Ask server to give money randomly:
MoneyService.GiveMeMoney.Fire();
// Advanced example, using promises to get money:
MoneyService.GetMoneyPromise().then((money) => {
print("Got money:", money);
});
Component.d.ts missing parameters
The Component.d.ts file appears to be missing the dt parameter for all the corresponding functions (RenderUpdate, HeartbeatUpdate, SteppedUpdate)
HeartbeatUpdate?(): void; -> HeartbeatUpdate?(dt?: number): void;
SteppedUpdate?(): void; -> SteppedUpdate?(dt?: number): void;
RenderUpdate?(): void; -> RenderUpdate?(dt?: number): void;
The changes above should hopefully mitigate the issue if I'm not mistaken, while keeping it optional to have said parameter.
Using classes with a service on controller breaks since version 0.7
We're currently blocked from upgrading @rbxts/knit
past version 0.6 because our "class method" no longer works. There are no errors and Knit reports that everything has started properly, but nothing runs. I have tried to diff the version and have found nothing which could cause this.
Our service and controller definitions look like this:
export const ExampleController = Knit.CreateController(
new (class ExampleController extends KnitController {
public Name = "ExampleController";
public KnitStart() {}
})(),
);
We do this because it is much easier to work in a class rather than an object (which is used by default).
I have gone into Knit's source and as far as I can tell, by the time that Knit.Start()
runs, all services and controllers no longer have their methods or properties. Maybe there was a change introduced that removes the class metatable?
Missing types from Component
Missing types from Component:
Component.Added
Component.Removed
These are fired whenever an instance of a component is created or removed, with the instance passed as the argument
EDIT:
Component.WaitFor second argument WaitFor should be optional
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.