{"id":13409735,"url":"https://github.com/Sleitnick/Knit","last_synced_at":"2025-03-14T15:30:32.423Z","repository":{"id":39904730,"uuid":"277660877","full_name":"Sleitnick/Knit","owner":"Sleitnick","description":"Lightweight game framework for Roblox","archived":true,"fork":false,"pushed_at":"2024-07-31T13:18:03.000Z","size":6395,"stargazers_count":562,"open_issues_count":0,"forks_count":89,"subscribers_count":37,"default_branch":"main","last_synced_at":"2024-07-31T20:38:06.392Z","etag":null,"topics":["framework","game","library","lua","luau","roblox"],"latest_commit_sha":null,"homepage":"https://sleitnick.github.io/Knit/","language":"Luau","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sleitnick.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"ko_fi":"sleitnick"}},"created_at":"2020-07-06T22:22:57.000Z","updated_at":"2024-07-31T13:19:08.000Z","dependencies_parsed_at":"2024-02-04T21:43:32.930Z","dependency_job_id":"972e28f6-9de7-4ed7-94ed-a987e43c1610","html_url":"https://github.com/Sleitnick/Knit","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2FKnit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2FKnit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2FKnit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2FKnit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sleitnick","download_url":"https://codeload.github.com/Sleitnick/Knit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243600477,"owners_count":20317281,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","game","library","lua","luau","roblox"],"created_at":"2024-07-30T20:01:03.067Z","updated_at":"2025-03-14T15:30:32.052Z","avatar_url":"https://github.com/Sleitnick.png","language":"Luau","readme":"[![Release](https://github.com/Sleitnick/Knit/actions/workflows/release.yaml/badge.svg)](https://github.com/Sleitnick/Knit/actions/workflows/release.yaml)\n[![CI](https://github.com/Sleitnick/Knit/actions/workflows/ci.yaml/badge.svg)](https://github.com/Sleitnick/Knit/actions/workflows/ci.yaml)\n[![Docs](https://github.com/Sleitnick/Knit/actions/workflows/docs.yaml/badge.svg)](https://github.com/Sleitnick/Knit/actions/workflows/docs.yaml)\n\n## :warning: No Longer Maintained :warning:\n\nKnit has been archived and will no longer receive updates.\n\nPlease [read here](/ARCHIVAL.md) for more information.\n\n# Knit\n\nKnit is a lightweight framework for Roblox that simplifies communication between core parts of your game and seamlessly bridges the gap between the server and the client.\n\nRead the [documentation](https://sleitnick.github.io/Knit/) for more info.\n\n## Install\n\nInstalling Knit is very simple. Just drop the module into ReplicatedStorage. Knit can also be used within a Rojo project.\n\n**Roblox Studio workflow:**\n\n1. Get [Knit](https://www.roblox.com/library/5530714855/Knit) from the Roblox library.\n1. Place Knit directly within ReplicatedStorage.\n\n**Wally \u0026 Rojo workflow:**\n\n1. Add Knit as a Wally dependency (e.g. `Knit = \"sleitnick/knit@^1\"`)\n1. Use Rojo to point the Wally packages to ReplicatedStorage.\n\n## Basic Usage\n\nThe core usage of Knit is the same from the server and the client. The general pattern is to create a single script on the server and a single script on the client. These scripts will load Knit, create services/controllers, and then start Knit.\n\nThe most basic usage would look as such:\n\n```lua\nlocal Knit = require(game:GetService(\"ReplicatedStorage\").Packages.Knit)\n\nKnit.Start():catch(warn)\n-- Knit.Start() returns a Promise, so we are catching any errors and feeding it to the built-in 'warn' function\n-- You could also chain 'await()' to the end to yield until the whole sequence is completed:\n--    Knit.Start():catch(warn):await()\n```\n\nThat would be the necessary code on both the server and the client. However, nothing interesting is going to happen. Let's dive into some more examples.\n\n### A Simple Service\n\nA service is simply a structure that _serves_ some specific purpose. For instance, a game might have a MoneyService, which manages in-game currency for players. Let's look at a simple example:\n\n```lua\nlocal Knit = require(game:GetService(\"ReplicatedStorage\").Packages.Knit)\n\n-- Create the service:\nlocal MoneyService = Knit.CreateService {\n\tName = \"MoneyService\",\n}\n\n-- Add some methods to the service:\n\nfunction MoneyService:GetMoney(player)\n\t-- Do some sort of data fetch\n\tlocal money = someDataStore:GetAsync(\"money\")\n\treturn money\nend\n\nfunction MoneyService:GiveMoney(player, amount)\n\t-- Do some sort of data fetch\n\tlocal money = self:GetMoney(player)\n\tmoney += amount\n\tsomeDataStore:SetAsync(\"money\", money)\nend\n\nKnit.Start():catch(warn)\n```\n\nNow we have a little MoneyService that can get and give money to a player. However, only the server can use this at the moment. What if we want clients to fetch how much money they have? To do this, we have to create some client-side code to consume our service. We _could_ create a controller, but it's not necessary for this example.\n\nFirst, we need to expose a method to the client. We can do this by writing methods on the service's Client table:\n\n```lua\n-- Money service on the server\n...\nfunction MoneyService.Client:GetMoney(player)\n\t-- We already wrote this method, so we can just call the other one.\n\t-- 'self.Server' will reference back to the root MoneyService.\n\treturn self.Server:GetMoney(player)\nend\n...\n```\n\nWe can write client-side code to fetch money from the service:\n\n```lua\n-- Client-side code\nlocal Knit = require(game:GetService(\"ReplicatedStorage\").Packages.Knit)\nKnit.Start():catch(warn):await()\n\nlocal MoneyService = Knit.GetService(\"MoneyService\")\n\nMoneyService:GetMoney():andThen(function(money)\n\tprint(money)\nend)\n```\n\nUnder the hood, Knit is creating a RemoteFunction bound to the service's GetMoney method. Knit keeps RemoteFunctions and RemoteEvents out of the way so that developers can focus on writing code and not building networking infrastructure.\n","funding_links":["https://ko-fi.com/sleitnick"],"categories":["Packages","Frameworks"],"sub_categories":["Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSleitnick%2FKnit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSleitnick%2FKnit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSleitnick%2FKnit/lists"}