This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| wrappingGenerator().listen((i) => print(i)); | |
| } | |
| Stream<int> wrappingGenerator() async* { | |
| yield 0; | |
| await for(int value in nestedGenerator()) { | |
| yield value; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // BLOC | |
| class ErrorBloc extends Bloc<ErrorBlocEvent, ErrorBlocState> { | |
| @override | |
| Stream<ClaimState> mapEventToState(ErrorBlocState currentState, ErrorBlocEvent event) async* { | |
| if (event is SomeEvent) { | |
| yield Processing(); | |
| final result = await _doSomething(); | |
| if(result.success) { | |
| yield Success(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/res/layout/activity_main.xml:1 | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| tools:context="io.getstream.thestream.MainActivity"> | |
| <EditText |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/java/io/getstream/thestream/MainActivity.kt:16 | |
| class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| val submit: Button = findViewById(R.id.submit) | |
| val userView: EditText = findViewById(R.id.user) | |
| submit.setOnClickListener { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/java/io/getstream/thestream/services/BackendService.kt:18 | |
| fun signIn(user: String) { | |
| authToken = post( | |
| "/v1/users", | |
| mapOf("user" to user) | |
| ) | |
| .getString("authToken") | |
| this.user = user | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/java/io/getstream/thestream/services/BackendService.kt:27 | |
| data class StreamCredentials(val token: String, val apiKey: String) | |
| fun getChatCredentials(): StreamCredentials { | |
| val response = post( | |
| "/v1/stream-chat-credentials", | |
| mapOf(), | |
| authToken | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // backend/src/controllers/v1/stream-feed-credentials/stream-feed-credentials.action.js:1 | |
| import dotenv from 'dotenv'; | |
| import stream from "getstream"; | |
| dotenv.config(); | |
| exports.streamFeedCredentials = async (req, res) => { | |
| try { | |
| const apiKey = process.env.STREAM_API_KEY; | |
| const apiSecret = process.env.STREAM_API_SECRET; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/java/io/getstream/thestream/services/ChatService.kt:14 | |
| object ChatService { | |
| private lateinit var client: ChatClient | |
| private lateinit var user: User | |
| fun init(context: Context, user: String, credentials: BackendService.StreamCredentials) { | |
| val chat = Chat | |
| .Builder(credentials.apiKey, context) | |
| .logLevel(ChatLogLevel.ALL) | |
| .build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- android/app/src/main/res/layout/activity_authed_main.xml:1 --> | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| android:id="@+id/container" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical"> | |
| <FrameLayout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // android/app/src/main/java/io/getstream/thestream/AuthedMainActivity.kt:8 | |
| class AuthedMainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_authed_main) | |
| val navigation = findViewById<BottomNavigationView>(R.id.navigation) | |
| navigation.setOnNavigationItemSelectedListener(navListener) |