I'm trying out the latest SST with the updated dem...
# help
j
I'm trying out the latest SST with the updated demo app. I already had a deployment of the demo app from many months ago, I was trying to update that deployment but its creating all new stacks. I think it would be good practice for me to figure out how to update existing stacks, rather than replace them. Or should I just try to keep the cognito user pool and the storage stack? Any tips? Thanks.
t
it's likely because of changes we made to the stack id
it's probably deploying new stacks called
<stage>-<app>-Stack
instead of
<stage>-<app>-stack
you can override the
id
in the index file per stack
j
Thanks, I'll give that a try.
BTW, I love the new syntax:
Copy code
app.stack(StorageStack).stack(ApiStack).stack(AuthStack).stack(FrontendStack);
could you recommend any reading to help me understand how that works?
t
I made a video explaining the thinking behind functional vs class:

https://www.youtube.com/watch?v=cqzgAJvUQCg&amp;t=5s

but are you curious about the underlying implementation?
j
I need to explore more, but I was curious how
use(...)
worked.
Thanks for the link, I'll check it out.
t
The typing for
use
is fairly simple, we take your input and return
ReturnType<typeof yourfunc>
j
I'm trying to understand how it gets the previous stacks in the chain from index.js and not just a new instance of the stack.
I watched the video. I think I understand it now, we're now defining stacks as functions, instead of classes. Now I'm wondering what if you need to pass two instances of a stack into another stack. Can you alias the function so that two instances can be passed in?
t
You can create a function that returns a function and do
Copy code
StackA = StackBuilder()
StackB = StackBuilder()
or define the stacks normally and call a common function
Copy code
function StackA(ctx) {
  return StackBuilder(ctx)
}

function StackB(ctx) {
  return StackBuilder(ctx)
}
where this pattern is weaker is fully dynamic stacks that aren't known at compile time. still possible but uglier
j
Thanks
t
in terms of getting the previous stacks, we just have a global object that keeps track of all initialized stacks
j
This is great. Thank you.