Title: Hyperstack.connect should behave nicely if passed a dummy value · Issue #159 · hyperstack-org/hyperstack · GitHub
Open Graph Title: Hyperstack.connect should behave nicely if passed a dummy value · Issue #159 · hyperstack-org/hyperstack
X Title: Hyperstack.connect should behave nicely if passed a dummy value · Issue #159 · hyperstack-org/hyperstack
Description: for example: class CurrentUser < HyperStore receives LoginOperation do |user| Hyperstack.connect(User.find_by_email(user.email)) end will not work, because connect needs the actual id, which will be unknown (i.e. a dummy value) until the...
Open Graph Description: for example: class CurrentUser < HyperStore receives LoginOperation do |user| Hyperstack.connect(User.find_by_email(user.email)) end will not work, because connect needs the actual id, which will b...
X Description: for example: class CurrentUser < HyperStore receives LoginOperation do |user| Hyperstack.connect(User.find_by_email(user.email)) end will not work, because connect needs the actual id, which wil...
Opengraph URL: https://github.com/hyperstack-org/hyperstack/issues/159
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Hyperstack.connect should behave nicely if passed a dummy value","articleBody":"for example:\r\n\r\n```ruby\r\nclass CurrentUser \u003c HyperStore\r\n receives LoginOperation do |user|\r\n Hyperstack.connect(User.find_by_email(user.email)) \r\n end\r\n```\r\n\r\nwill not work, because connect needs the actual id, which will be unknown (i.e. a dummy value) until the next fetch cycle completes.\r\n\r\nSo internally connect needs to make sure that id is loaded before connecting:\r\n\r\n```ruby\r\nmodule Hyperstack\r\n def self.connect(*channels)\r\n channels.each do |channel|\r\n if channel.is_a? Class\r\n IncomingBroadcast.connect_to(channel.name)\r\n elsif channel.is_a?(String) || channel.is_a?(Array)\r\n IncomingBroadcast.connect_to(*channel)\r\n elsif channel.id\r\n Hyperstack::Model.load do\r\n channel.id\r\n end.then do |id|\r\n IncomingBroadcast.connect_to(channel.class.name, id)\r\n end\r\n else\r\n raise \"cannot connect to model before it has been saved\"\r\n end\r\n end\r\n end\r\nend\r\n```\r\n\r\n","author":{"url":"https://github.com/catmando","@type":"Person","name":"catmando"},"datePublished":"2019-04-09T21:04:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/159/hyperstack/issues/159"}
| 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:1cc7fa48-be35-6ec2-a765-460a9d5ac3c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB10:189F37:83FC93:A8D53F:6992237C |
| html-safe-nonce | b4079bc0821f5f0e5579b7a730f91868816badad957c213c874af863a4dcf777 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjEwOjE4OUYzNzo4M0ZDOTM6QThENTNGOjY5OTIyMzdDIiwidmlzaXRvcl9pZCI6Ijc2NDcxNzI2NjY3MTY0MTQ2OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ce53385eccc4a1dea365b7feda0386c0506e8a39f44f63996a27e8346922f251 |
| hovercard-subject-tag | issue:431196250 |
| 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/hyperstack-org/hyperstack/159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0485215e151ed5666a7d663d089ac97484553b40d8b908ee517ccdc9246e9de7/hyperstack-org/hyperstack/issues/159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0485215e151ed5666a7d663d089ac97484553b40d8b908ee517ccdc9246e9de7/hyperstack-org/hyperstack/issues/159 |
| og:image:alt | for example: class CurrentUser < HyperStore receives LoginOperation do |user| Hyperstack.connect(User.find_by_email(user.email)) end will not work, because connect needs the actual id, which will b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | catmando |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/hyperstack-org/hyperstack git https://github.com/hyperstack-org/hyperstack.git |
| octolytics-dimension-user_id | 34562730 |
| octolytics-dimension-user_login | hyperstack-org |
| octolytics-dimension-repository_id | 145879576 |
| octolytics-dimension-repository_nwo | hyperstack-org/hyperstack |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 145879576 |
| octolytics-dimension-repository_network_root_nwo | hyperstack-org/hyperstack |
| 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 | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width