mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 09:12:02 +00:00
e2b25c8c9d
Summary: Packager can take a long time to load and the progress is usually displayed in another window (Terminal). I'm adding support for showing a UI inside React Native app for packager's progress when loading a bundle. This is how it will work: 1. React Native sends request to packager with `Accept: multipart/mixed` header. 2. Packager will detect that header to detect that client supports progress events and will reply with `Content-Type: multipart/mixed`. 3. While building the bundle it will emit chunks with small metadata (like `{progress: 0.3}`). In the end it will send the last chunk with the content of the bundle. 4. RN runtime will be receiving the events, for each progress event it will update the UI. The last chunk will be the actual bundle which will end the download process. This workflow is totally backwards-compatible -- normally RN doesn't set the `Accept` header. Reviewed By: mmmulani Differential Revision: D3845684 fbshipit-source-id: 5b3d2c5a4c6f4718d7e5de060d98f17491e82aba
23 lines
791 B
Objective-C
23 lines
791 B
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
typedef void (^RCTMultipartCallback)(NSDictionary *headers, NSData *content, BOOL done);
|
|
|
|
|
|
// RCTMultipartStreamReader can be used to parse responses with Content-Type: multipart/mixed
|
|
// See https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
|
|
@interface RCTMultipartStreamReader : NSObject
|
|
|
|
- (instancetype)initWithInputStream:(NSInputStream *)stream boundary:(NSString *)boundary;
|
|
- (BOOL)readAllParts:(RCTMultipartCallback)callback;
|
|
|
|
@end
|