{"id":20572727,"url":"https://github.com/molnarmark/multex","last_synced_at":"2025-03-06T10:22:38.322Z","repository":{"id":92790921,"uuid":"123726490","full_name":"molnarmark/multex","owner":"molnarmark","description":"🏗️ Flux Implementation done in Multi Theft Auto","archived":false,"fork":false,"pushed_at":"2018-03-08T19:35:11.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T04:56:36.213Z","etag":null,"topics":["flux","flux-application-architecture","flux-architecture","mta-server","mtasa","mtasa-lua","multi-theft-auto"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/molnarmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-03-03T19:57:34.000Z","updated_at":"2024-04-13T13:01:25.000Z","dependencies_parsed_at":"2023-03-20T02:03:14.676Z","dependency_job_id":null,"html_url":"https://github.com/molnarmark/multex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molnarmark%2Fmultex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molnarmark%2Fmultex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molnarmark%2Fmultex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/molnarmark%2Fmultex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/molnarmark","download_url":"https://codeload.github.com/molnarmark/multex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242188288,"owners_count":20086340,"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":["flux","flux-application-architecture","flux-architecture","mta-server","mtasa","mtasa-lua","multi-theft-auto"],"created_at":"2024-11-16T05:23:33.252Z","updated_at":"2025-03-06T10:22:38.302Z","avatar_url":"https://github.com/molnarmark.png","language":"Lua","readme":"# Multex\r\n[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)\r\n[![Open Source Love](https://badges.frapsoft.com/os/mit/mit.svg?v=102)](https://github.com/ellerbrock/open-source-badge/)\r\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\r\n\r\n## Introduction\r\nMultex is an implementation of the `Flux` Architecture by [Facebook](http://facebook.com) for the [Multi Theft Auto](http://mtasa.com) modification.\\\r\nYou can learn more about how `Flux` works [here](https://facebook.github.io/flux/).\r\n\r\n### Getting Started\r\nCreate a store by calling the exported createStore function:\r\n```lua\r\nlocal store = loadstring(createStore())()\r\n```\r\nYou can set the initial state of a store by calling `setInitialState` on it:\r\n```lua\r\nstore:setInitialState({counter = 0})\r\n```\r\n\r\n### Events\r\nYou can also subscribe to various events that happen on the store main ones being:\r\n- update\r\n- computed_update\r\n\r\n### Computed Properties\r\nComputed properties introduced in `Vuex` are also available in Multex.\\\r\nYou can subscribe to a property change like so:\r\n```lua\r\nstore:setComputedProperty(\"counter\", function()\r\n  outputChatBox(\"Counter has changed. Let's do something.\")\r\nend)\r\n```\r\n### Hooks\r\nMultex also offers you two very simple hooks you can use, those being `beforeAction` and `afterAction`.\\\r\nYou can use them like so:\r\n```lua\r\nstore:setHook(\"beforeAction\", function()\r\n  outputChatBox(\"An action is about to take place.\")\r\nend)\r\n```\r\n\r\n### Practical Example\r\nMultex uses the traditional action handlers with a simple dispatch method.\\\r\nHere is a little practical example showing you the power of `Multex`.\r\n\r\n```lua\r\nlocal store = loadstring(createStore())()\r\nstore:setInitialState({counter = 0})\r\n\r\n-- You can subscribe to the change of a property.\r\nstore:setComputedProperty(\"counter\", function()\r\n  outputChatBox(\"Counter has changed.\")\r\nend)\r\n\r\n-- Let's handle some actions!\r\nstore:onAction(function(name, payload)\r\n  if name == \"increment\" then\r\n    outputChatBox(\"Increment action called with payload of \" .. payload.value)\r\n    local state = store:getState()\r\n    store:setState({counter = state.counter + 1})\r\n  end\r\nend)\r\n\r\n-- The update event is emitted whenever the state changes via setState()\r\nstore:on(\"update\", function()\r\n  local counter = store:getState().counter\r\n  outputChatBox(\"State updated. Counter is now \" .. counter)\r\nend)\r\n\r\n-- Let's create some actions for our store\r\nlocal actions = {\r\n  increment = function()\r\n    store:dispatch(\"increment\", {value = 1})\r\n  end,\r\n}\r\n\r\nactions.increment()\r\nactions.increment()\r\nactions.increment()\r\nactions.increment()\r\nactions.increment()\r\n-- counter is now 5\r\n```\r\n\r\n### Fancy buying me a beer?\r\nIf this project was helpful to you, you can buy me a beer if you feel like doing so. 🙂\r\n\r\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YM7E34E2LT4D8)","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=YM7E34E2LT4D8"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolnarmark%2Fmultex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmolnarmark%2Fmultex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmolnarmark%2Fmultex/lists"}