{"id":17133269,"url":"https://github.com/gilbox/simflux","last_synced_at":"2025-04-13T08:11:52.117Z","repository":{"id":23376558,"uuid":"26738022","full_name":"gilbox/simflux","owner":"gilbox","description":"simplifying wrapper around Facebook's Flux implementation","archived":false,"fork":false,"pushed_at":"2015-04-03T16:01:11.000Z","size":352,"stargazers_count":21,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T09:03:44.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/gilbox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-17T03:19:59.000Z","updated_at":"2021-09-07T13:36:13.000Z","dependencies_parsed_at":"2022-08-29T19:02:08.021Z","dependency_job_id":null,"html_url":"https://github.com/gilbox/simflux","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/gilbox%2Fsimflux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilbox%2Fsimflux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilbox%2Fsimflux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilbox%2Fsimflux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilbox","download_url":"https://codeload.github.com/gilbox/simflux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248664503,"owners_count":21141974,"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":[],"created_at":"2024-10-14T19:41:47.372Z","updated_at":"2025-04-13T08:11:52.094Z","avatar_url":"https://github.com/gilbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"simflux\n=======\n\nFramework-agnostic, simple Flux wrapper on top of Facebook's Flux\n\nsimflux-viz\n-----------\n\n**[simflux-viz](https://github.com/gilbox/simflux-viz)** is a plugin for\n**[vizone](https://github.com/gilbox/vizone)**, a chrome extension and visualization library\nthat aids developers to understand application flow.\n\nhow?\n----\n\n    var dispatcher = new simflux.Dispatcher();\n\n    // an object qualifies to be a store if it has methods\n    // named the same as the actions it should handle\n    var appStore = {\n      todos: [],\n      addTodo(payload) { \n        dispatcher.waitFor([otherStore, anotherStore]);\n        this.todos.push({\n          todo: payload.todo,\n          priority: payload.priority\n        });\n      },\n      removeTodo(payload) { ... }\n    }\n    \n    // register appStore with Flux\n    dispatcher.registerStore(appStore);\n    \n    // all async ops should be handled by the Action Creator\n    var actionCreator = {\n      addTodo(todo, priority) {\n        doSomethingAsync.then(function() {\n          dispatcher.dispatch('addTodo', {todo, priority});\n        });\n      }\n    }\n\n    // register appStore with Flux\n    dispatcher.registerActionCreator(actionCreator);\n    \n    // in the view: do something!\n    actionCreator.addTodo({ todo: 'My Todo', priority: 'top priority' });\n\n\nwhy?\n----\n\n- Less boilerplate\n- Easier to read\n\ndifferences\n-----------\n\n### dispatch\n\nFlux:\n\n    dispatcher.dispatch( { type: 'ACTION_TYPE', data: { allthe: data} );\n\nsimflux:\n\n    dispatcher.dispatch('ACTION_TYPE', arg1, arg2, ... );\n    \n\n### register, waitFor\n\nFlux:\n\n    var todoStore = {\n      handleAllActions(payload) {\n        switch(payload.type) {\n          case 'addTodo':\n            dispatcher.waitFor([anotherStore.dispatcherToken]);\n            ...\n            break;\n        }\n      }\n    };\n\n    todoStore.dispatcherToken = dispatcher.register(todoStore.handleAllActions);\n\nsimflux:\n\n    var todoStore = {\n      addTodo(payload) {\n        dispatcher.waitFor([anotherStore])\n        ...\n      }\n    }\n\n    dispatcher.registerStore(todoStore);\n\n\n\naccess the flux dispatcher\n--------------------------\n\nOccasionally, you might want the extra power that Facebook's dispatcher gives you, in which case you can access the instance of the Facebook dispatcher that simflux uses internally via: `dispatcher.fluxDispatcher`\n\nFor example, if you want a store to handle any action that begins with `add`:\n\n    var dispatcher = new simflux.Dispatcher();\n    \n    var appStore = {\n      handleActions(o) {\n        var action = o.action,\n            payload = o.args[0];\n        \n        if (action.indexOf('add') === 0) {\n            // do something with args\n        }\n      }\n    }\n    \n    // register appStore.handleActions with Flux\n    dispatcher.fluxDispatcher.register(appStore.handleActions);\n\ndemo\n----\n\n- [angular-simflux-experiment](https://github.com/gilbox/angular-simflux-experiment): Flux in angularjs\n\n- [angular-flux-routing-example](https://github.com/gilbox/angular-flux-routing-example): Another angularjs demo created for the article [Achieving reasonable and scalable routing in AngularJS with Flux](https://medium.com/@gilbox/achieving-reasonable-and-scalable-routing-in-angularjs-with-flux-2655e06cd5ee)\n\n\nrequirements\n------------\n\n- [Facebook's Flux](https://github.com/facebook/flux) Implementation\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilbox%2Fsimflux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilbox%2Fsimflux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilbox%2Fsimflux/lists"}