Title: Separate visual components from glue components · Issue #547 · coder/coder · GitHub
Open Graph Title: Separate visual components from glue components · Issue #547 · coder/coder
X Title: Separate visual components from glue components · Issue #547 · coder/coder
Description: RFC As a developer I want to clearly separate the visual components from the glue components as we bring in V1 features into V2 so that we can easily story book those components that do not access global state or send API calls and keep ...
Open Graph Description: RFC As a developer I want to clearly separate the visual components from the glue components as we bring in V1 features into V2 so that we can easily story book those components that do not access ...
X Description: RFC As a developer I want to clearly separate the visual components from the glue components as we bring in V1 features into V2 so that we can easily story book those components that do not access ...
Opengraph URL: https://github.com/coder/coder/issues/547
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Separate visual components from glue components ","articleBody":"[RFC](https://www.notion.so/coderhq/v2-Frontend-State-Management-APPROVED-e5ccb3c6357649f9a9dc1a1b2a1b7a99#a874064aa72a4391af7f94c264ed071a)\r\n\r\nAs a developer I want to clearly separate the visual components from the glue components as we bring in V1 features into V2 so that we can easily story book those components that do not access global state or send API calls and keep our code lean and easy to develop. \r\n\r\n**glue component**: term for components that access global state or send API calls and are thus not easy to unit test or storybook. They are also known as “connected,” “smart,” or “impure,” but I like “glue” to encourage us to only use them as a glue layer between logic and view, and keep them as lean as possible. Glue components send messages, render org data and error messages. \r\n\r\n**visual component**: components that don’t use global state or send API calls. not “pure” components because they can hold component state, such as a toggle button that you can click on or off or an input that can hold unsubmitted text. What they render depends only on their props and that kind of local user interaction, resulting in components that take maximize what we can easily unit test and put in Storybook. (It may also use the theme, which is delivered via Context Provider, and which unit tests and Storybook can handle.)\r\n\r\nFurther: \r\nFor separation of concerns, use the global state machines to encapsulate API calls. For instance, the Organizations machine knows how to add, delete, update, and read organizations from the backend, and the glue components do not (they merely send messages like `\"GET_ORGANIZATION\"` and render either organization data or error messages. \r\n\r\nThis will mean: \r\n- DRYer component code - instead of two page components writing the same promise handling code, the global state machine writes it once\r\n- leaner and easier to read glue components - I expect sending messages to the global state machine and receiving its state to amount to less code and fewer conditions in the components than handling the API calls there\r\n- the ability to change the API contract with minimal impact on the frontend codebase - just edit the global state machine","author":{"url":"https://github.com/misskniss","@type":"Person","name":"misskniss"},"datePublished":"2022-03-24T04:26:48Z","url":"https://github.com/coder/coder/issues/547"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9eb4b071-a057-2d08-9794-930dc9eca3e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DEB6:154D88:F9E947:13E1AAB:6B014DB9 |
| html-safe-nonce | 6baa1a6846863395f658ef0c18a8be328154307226df485666c8f54e92d5d219 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUI2OjE1NEQ4ODpGOUU5NDc6MTNFMUFBQjo2QjAxNERCOSIsInZpc2l0b3JfaWQiOiIxNjI4NDg4MDA1MTM0MTQyOTA1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d66beed0bf771857f9ca0b443fec6c2f64c11298c37db68e1556cd583c2a192f |
| hovercard-subject-tag | issue:1178980318 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/547/issue_layout |
| twitter:image | https://opengraph.githubassets.com/22010a786a60d3152daf8dde85df1b25f53aef4a284acd3622892296077a3b50/coder/coder/issues/547 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/22010a786a60d3152daf8dde85df1b25f53aef4a284acd3622892296077a3b50/coder/coder/issues/547 |
| og:image:alt | RFC As a developer I want to clearly separate the visual components from the glue components as we bring in V1 features into V2 so that we can easily story book those components that do not access ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | misskniss |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width