Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
35 lines (30 sloc) 1.15 KB
library seaside.session;
import 'package:shelf/shelf.dart';
import 'component.dart';
import 'continuation.dart';
import 'keys.dart';
/// User session persistent as long as the user is interacting with it.
class Session {
final String sessionKey;
final Map<String, Continuation> _continuations = {};
final Component component;
Session(this.sessionKey, this.component);
/// Handles the creation and resolution of continuations, including the
/// rendering of the response using the root component.
Response call(Request request) {
final continuationKey = createContinuationKey();
final continuation = Continuation(sessionKey, continuationKey, component);
_continuations[continuationKey] = continuation;
final headContents = => component.head).join();
final bodyContents = component.body(continuation);
return Response.ok('''
''', headers: {'Content-Type': 'text/html'});