Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cashay #64

Merged
merged 5 commits into from Jun 16, 2016
Merged

Cashay #64

merged 5 commits into from Jun 16, 2016

Conversation

mattkrick
Copy link
Member

in efforts to keep commits smaller & more frequent, i'd like to merge this. It doesn't do much more than a login + redirect in cashay, but then again that was a surprising amount of work.

remove redux-optimistic-ui (cleanup)
fix ACtionHTTPTransport
Update to cashay 0.8.1
perform auth through cashay
@@ -19,8 +19,8 @@
"build": "rimraf build && concurrently \"npm run build:client\" \"npm run build:server\"",
"bs": "rimraf build && concurrently \"npm run build:client\" \"npm run build:server\" \"npm run start\"",
"quickstart": "rimraf build && concurrently \"npm run db:migrate\" \"npm run build:client\" \"npm run build:server\" \"npm run start\"",
"build:client": "NODE_ENV=production webpack -p --config ./webpack/prod.babel.js",
"build:server": "npm run build:theme && NODE_ENV=production webpack -p --config ./webpack/server.babel.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these slow me down! ditching uglify makes dev much more fun. maybe we should write a separate deploy script?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use npm run dev and leave build:client and build:server alone?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i use npm run bs when working on the server. that way, i don't need to rebuild the client for every change i make to the server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! Seems like adding build:deploy might be the way to go then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I can do that later)

@jordanh
Copy link
Contributor

jordanh commented Jun 16, 2016

Just ran it. Works great! Fix linting errors then, looking good! 😎

@jordanh jordanh merged commit 94de419 into master Jun 16, 2016
@jordanh jordanh removed the pr review label Jun 16, 2016
@jordanh jordanh deleted the cashay branch June 16, 2016 06:52
@@ -42,6 +42,8 @@ query {
const mutationHandlers = {
updateUserWithAuthToken(optimisticVariables, dataFromServer, currentResponse) {
if (dataFromServer) {
// TODO: modifing params by reference is stylisitically problematic,
// can interface be pure and return new value intead?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's always good to be aware of mutating objects, but it shouldn't be a hard rule.
For example (since i learned about plugins yesterday...) almost every webpack plugin does this because it hands you a compilation object and you stick something on it, eg compilation.assets[myFoo] = 'newFoo!'. What else are they gonna do, hand you the parent of compilation and make you return a whole new compilation object? Nahhhh

Cashay does allow you to return a pure object, but here's how that looks:

Option 1:

const myResponse = JSON.parse(JSON.stringify(currentResponse));
myResponse.foo = 2;
return myResponse;

Option 2:

return Object.assign({}, currentResponse, {
  cachedUserAndToken: Object.assign({}, currentResponse.cachedUserAndToken, {
    user: Object.assign({}, currentResponse.cachedUserAndToken.user, {
      id: dataFromServer.cachedUserAndToken.user.id
    }
  })
}

So I guess the answer is, want to play by the rules? Go ahead, no one is stopping you. But, if you wanna be a bad boy (without any risk!), go ahead & mutate 😈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants